what's wrong with my code below? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

what's wrong with my code below?

fun main(args: Array<String>) { var a=readLine()!!.toDouble(); var b=readLine()!!.toDouble(); val Double c="subtraction is${a-b}" print(c); }

4th Jan 2019, 6:40 PM
Cankardeş Cancan
Cankardeş Cancan - avatar
1 Answer
+ 3
in Sololearn you can only ask input for one time. Also you are storing a string into a double variable. If you want to declare a type of a variable val b : Double = 3.5; fun main(args: Array<String>) { var a : Double = readLine()!!.toDouble(); var b : Double = readLine()!!.toDouble(); val c = "subtraction is " + (a-b); print(c); }
4th Jan 2019, 7:21 PM
Toni Isotalo
Toni Isotalo - avatar