+ 1

My code has errors. This looks right to me, though. What is wrong?

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 Wrong Solution=> fun main(args: Array<String>) { var years = readLine()!!.toInt() var liters = readLine()!!.toInt() var days =readLine()!!.toInt() println(years * days * liters) }

28th Feb 2023, 11:47 AM
The Tina Experience
The Tina Experience - avatar
8 Réponses
+ 5
Seems to me the task only requires us to read one input - number of years. Neither number of liter per day nor days per year needs to be read in. So try make <days> and <liters> constant values to be used in calculation, or just use integer literal in their place.
28th Feb 2023, 12:05 PM
Ipang
+ 3
Praveen Kumar please delete your offensive comment.
28th Feb 2023, 1:15 PM
Ausgrindtube
Ausgrindtube - avatar
+ 3
Awesome work matey! Glad you got there. You were on the right path, just as you said, you made it too hard on yourself. Happy coding!
28th Feb 2023, 6:23 PM
Ausgrindtube
Ausgrindtube - avatar
+ 2
Thanks Ipang
28th Feb 2023, 12:19 PM
The Tina Experience
The Tina Experience - avatar
+ 2
I finally did it you guys. Before, I was way out in left field over complicating things. Here is the answer: fun main(args: Array<String>) { var years = readLine()!!.toInt() val days = 365 val liters = 15 println(years * days * liters) }
28th Feb 2023, 3:12 PM
The Tina Experience
The Tina Experience - avatar
+ 1
Thanks Ausgrindtube. I just ignored that guy. We are all here to learn.
28th Feb 2023, 2:56 PM
The Tina Experience
The Tina Experience - avatar
+ 1
Thanks guys!
28th Feb 2023, 7:29 PM
The Tina Experience
The Tina Experience - avatar