- 1
Hello can someone help me solve the challenges in kotlin?
I have completed all the modules, but I can't complete the projects in it, it has multiple test cases but I can't write code to solve all, the solution I write solve only one test case
12 odpowiedzi
+ 5
Code_wizard💯🔥
I have already explained it. Check my comments again.
Don't solve blindly or with ready-made answers. You won't learn it.
Re-read lessons again, if you don't understand.
+ 4
Code_wizard💯🔥
You cannot declare variable starting with capital letter.
var years = readLine()!!.toInt() => [means it's going to take input and convert into integer]
When you are taking input, you don't need to assign consumption value of water. Here, you have to year [not consumption]
You can solve it this way & it will give you correct output. ⬇️
var years = readLine()!!.toInt()
println(years*365*15)
//try to understand logic behind given problem. It will be easy to solve other problems
// happy learning 👍
+ 3
Share the problem description, along with your attempt of code
+ 3
Code_wizard💯🔥
Did you understand logic behind solving the problem?
0
Ok
This the 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.
Sample Input
5
Sample Output
27375
The water consumption in 5 years would be: 5*365*15 = 27375
//Default code
Var years =readLine()!!. toInt()
// My code
Var = consumption = 2*365*15
Println(consumption)
0
Thanks it worked👐
0
Not really... If you could explain a bit, that would be great
0
fun main(args: Array<String>) {
var years =readLine()!!. toInt()
println(you don't need assign consumption o water that could be year's no need to specially mentioning year's too your TIP in this section only)
}
0
it's a quite simple!!
fun main(args: Array<String>) {
var years = readLine()!!.toInt()
var consuption = years*15*365
println(consuption)
}
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()
var consumation= years*365*15 //logic
println(consumation)
}
0
IT WORKED:
fun main(args: Array<String>) {
var years = readLine()!!.toInt()
var consuption = years*15*365
println(consuption)
}