Who can solve my kotlin first project? i am failed many times i can't understand it | Sololearn: Learn to code for FREE!

0

Who can solve my kotlin first project? i am failed many times i can't understand it

Help me

12/3/2021 6:03:22 PM

Ytbarek Debalke

38 Answers

New Answer

+2

Each day a family consumes 15 liters of water. Given the number of years as input, you need to calculate and output the amount of water consumed in that period. Sample Input 5 Sample Output 27375 The water consumption in 5 years would be: 5*365*15 = 27375

+2

Ytbarek Debalke looks like you don't know programming nor kotlin. First learn the concepts then you can easily write the program.

+2

Ytbarek Debalke Yes, Kashyap Kumar ⭕ is right. Learn the concepts first, very carefully, as many times till you understand it well. Also learn basic syntax of the language.👍Just try hard👍

+1

A͢J - S͟o͟l͟o͟H͟e͟l͟p͟e͟r͟ Your Reply 8-9 min before was really funny😂😂

+1

Thank you i tried and i was closed thanks to all of you i will try hardly and i solve it

+1

Ytbarek Debalke The number of years. That's in the challenge description. So, take the number of years as an user input, then use it in the formula. But, from the talk above, you do need to study better programming concepts. This is way more important than the languages themselves. When you get the concepts, you can code in any language. Before that, you'll bang your head to the wall on every simple question, like this one.

+1

Ytbarek Debalke Looks like you understand the math involved in the question just fine. However, writing a good program involves more than just solving the problem for one particular input case. You need to be able to give the solution no matter what value the user inputs as long as the input is valid of course (a numeric input not a text input). You put in println(2*15*365) which gives the number of litres after 2 years but what if the user wants the number of litres after 7 years or any other number of years. The way you've written your code you'd have to change your code for every single input value your user wants to input. You need to read an input value for number of years from the user of your program and use that value to calculate the output that you need. This is one of the basic requirements for a program. It should be able to take whatever input the user gives, decide if it's valid input and if it is, calculate the output. Once your program can do that you'll be able to get past this project.

0

Show your attempts water consumption: 15 litre/day then in n year? where n is input 1 year = 365 days.

0

Ok wait me

0

Here it is

0

Ytbarek Debalke This is the problem not your solution. Where is your solution?

0

fun main(args: Array<String>) { var years = readLine()!!.toInt() }

0

This is the code

0

Ytbarek Debalke This code is already given. Where you are getting problem to understand? It is simple. Water consumption: 1 day = 15 litre Then in n years = ? //Where n is input How many days in 1 year?

0

0

I think You can't solve it

0

Ytbarek Debalke Why should we do? Even I already explained you. 1 year = 365 days 1 day = 15 litre Then 365 days = ? litre

0

So, how can i add in my code

0

Please help me you are a good person in this programming language

0

Ytbarek Debalke You have completed 88 % of kotlin course. Still asking how to do that. 1 day = 15 litre 365 days = 15 * 365 For n years (where n is input) = n * 15 * 365 This is just a simple multiplication.