0
Why this code is not working?
fun main(args: Array<String>) { val num1 : Int = readLine()!!.toInt() val num2 : Int = readLine()!!.toInt() print(num1 + num2) }
5 Respuestas
+ 7
this is your updated code print statement should be like this way
println("The sum is ${num1 + num2}")
updated code:-
fun main(args:Array<String>){
val num1: Int = readLine()!!.toInt()
val num2: Int = readLine()!!.toInt()
println("The sum is ${num1 + num2}") }
You have tryed good just do add something like this way for easy understanding.
fun main(args:Array<String>){
var num1: Int
var num2: Int
println("Enter the first number")
num1 = readLine()!!.toInt()
println("Enter the second number")
num2 = readLine()!!.toInt()
println("The sum is ${num1 + num2}") }
+ 7
Jaikaran Saini it's working properly try by giving proper input
https://code.sololearn.com/cPMY0rgYGlJK/?ref=app
+ 1
Sorry but your updated code is also not working. It says
Java.lang.numberformatexception
+ 1
No it's not really working I don't know if my complier is working properly or I have any problems in my mobile but it showing same problem
+ 1
Please can help me?😢