TheBulgarianWolf

Kotlin_Break

Mar 17th, 2021
764
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 0.46 KB | None | 0 0
  1. fun main(args: Array<String>) {
  2.     var sum = 0
  3.     var number: Int
  4.  
  5.     while (true) {
  6.         print("Enter a number: ")
  7.         number = readLine()!!.toInt()
  8.  
  9.         if (number == 0)
  10.             break
  11.  
  12.         sum += number
  13.     }
  14.  
  15.     print("sum = $sum")
  16.     println()
  17.     first@ for (i in 1..4) {
  18.  
  19.         second@ for (j in 1..2) {
  20.             println("i = $i; j = $j")
  21.  
  22.             if (i == 2)
  23.                 break@first
  24.         }
  25.     }
  26. }
Add Comment
Please, Sign In to add comment