- 4

Water Consumption Kotlin

Need Help with this problem. 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. The water consumption in 5 years would be: 5*365*15 = 27375 What would this look like in Kotlin

17th Feb 2021, 8:19 PM
Garrett Boren
Garrett Boren - avatar
14 Respostas
+ 7
https://code.sololearn.com/cdizckmrtxM2/?ref=app This will help you. But you should always attempt it first then show your attempts here. people will correct you so that you learn from your mistakes
21st Feb 2021, 5:11 PM
Sharique Khan
Sharique Khan - avatar
+ 5
fun main(args: Array<String>) { var years = readLine()!!.toInt() println(years * 365 * 15) }
30th Mar 2021, 2:05 PM
Yosef Sahle
Yosef Sahle - avatar
+ 3
Garrett Boren, show. your. attempt.
18th Feb 2021, 12:15 AM
Dino Wun (Use the search bar plz!)
Dino Wun (Use the search bar plz!) - avatar
+ 2
Please add-show your attempt so the community can help you more easily :) Btw for resolving it, just make a variable that stores the value of a readLine(). Then just put this variable instead the 5, and Mission Completed!
18th Feb 2021, 2:32 PM
Matthew
Matthew - avatar
+ 2
fun main(args: Array<String>) { var years = readLine()!!.toInt() var res = years*365*15 println(res) }
6th Apr 2021, 8:14 PM
Maryem Mabrouk
Maryem Mabrouk - avatar
+ 2
fun main(args: Array<String>) { var years = readLine()!!.toInt() var res = years*365*15 println(res) }
26th Apr 2021, 7:57 AM
Karthick Balaji
Karthick Balaji - avatar
+ 1
This is my take o it: fun main(args: Array<String>) { var years = readLine()!!.toInt() var liters = 15 println(years * 365 * liters) } My first attempt was fun main(args: Array<String>) { var years = readLine()!!.toInt() var liters = readLine()!!.toInt() println(years * 365 * liters) Whit this attempt, I encounter a Java error Can someone explain to me the error with this attempt?
19th Jan 2022, 4:07 PM
SevenPRD
SevenPRD - avatar
0
To help you out, look at Basic Concepts lesson 6.1, the input statement code is already given to you, all you need is the output statement and the project is complete.
21st Feb 2021, 10:19 AM
Erik Jensen
Erik Jensen - avatar
0
why is test case 2 not getting unlocked. even if my test case 1 is correct.
28th Apr 2021, 4:06 AM
Saurav Singh
Saurav Singh - avatar
0
fun main(args: Array<String>) { var years = readLine()!!.toInt() var res = years*365*15 println(res) }
7th May 2021, 11:40 AM
Alharith Yousif
Alharith Yousif - avatar
0
fun main(args: Array<String>) { var years = readLine()!!.toInt() println(years * 365 * 15) It did work
30th Sep 2021, 10:26 AM
Akinyele Shakirullahi
Akinyele Shakirullahi - avatar
0
short and good! fun main(args: Array<String>) { var years = readLine()!!.toInt() var res = years*365*15 println(res) }
5th Oct 2022, 3:42 PM
Marcel KrÀttli
0
fun main(args: Array<String>){ var years = readLine()!!.toInt() printIn(years*365*15) } I had used that method above for water consumption project and still not working. Is there anything missing?
18th Mar 2023, 12:49 AM
Nyuon Khoryom Nyuon
0
the number of years: 5 The total amount of water consumed is 27375 liters.
6th Jun 2023, 1:15 PM
EAM RATHA | ឱៀម រដ្ឋា
EAM RATHA | ឱៀម រដ្ឋា - avatar