使用 https://rextester.com/l/kotlin_online_compiler online kotlin
/*
範例輸入
world
C++
mary
範例輸出
hello, world
hello, C++
hello, mary
*/
fun main (argument: Array <String>) {
//coding180.com
print ("Enter first value:")
val value1 = readLine () !!. toInt ()
print ("Enter second value:")
val value2 = readLine () !!. toInt ()
val sum = value1 + value2
println ("The sum of $value1 and $value2 is $sum")
val product = value1 * value2
println ("The product of $value1 and $value2 is $product")
}
輸入資料
12
23
輸出資料
Enter first value:Enter second value:The sum of 12 and 23 is 35 The product of 12 and 23 is 276
使用 https://www.jdoodle.com/compile-kotlin-online
//Program created for https://beginnersbook.com
fun main(args: Array<String>) {
print("Write anything here: ")
val enteredString = readLine()
println("You have entered this: $enteredString")
print("Write any number: ")
val number = Integer.valueOf(readLine())
println("The entered number is: $number")
}
沒有留言:
張貼留言