- 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
14 Antworten
+ 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
+ 5
fun main(args: Array<String>) {
var years = readLine()!!.toInt()
println(years * 365 * 15)
}
+ 3
Garrett Boren, show. your. attempt.
+ 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!
+ 2
fun main(args: Array<String>) {
var years = readLine()!!.toInt()
var res = years*365*15
println(res)
}
+ 2
fun main(args: Array<String>) {
var years = readLine()!!.toInt()
var res = years*365*15
println(res)
}
+ 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?
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.
0
why is test case 2 not getting unlocked. even if my test case 1 is correct.
0
fun main(args: Array<String>) {
var years = readLine()!!.toInt()
var res = years*365*15
println(res)
}
0
fun main(args: Array<String>) {
var years = readLine()!!.toInt()
println(years * 365 * 15)
It did work
0
short and good!
fun main(args: Array<String>) {
var years = readLine()!!.toInt()
var res = years*365*15
println(res)
}
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?
0
the number of years: 5
The total amount of water consumed is 27375 liters.