SHARE
TWEET

Untitled

a guest Nov 17th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.*
  2. fun main(args: Array<String>) {
  3.     val reader = Scanner(System.`in`)
  4.     print("Zadaj prvé čslo: ")
  5.         val first = reader.nextDouble()
  6.     println("Zadaj druhé číslo:")
  7.         var second = reader.nextDouble()                
  8.     println("Zadaj tretie číslo:")
  9.         var third = reader.nextDouble()
  10.     println("Zadaj štvrté číslo:")                    
  11.         var fourth = reader.nextDouble()
  12.     println("Zadaj piate číslo:")                              //zadáme čísla
  13.         var fifth = reader.nextDouble()
  14.     println("Zadaj šieste číslo:")
  15.         var sixth = reader.nextDouble()
  16.     println("Zadaj siedme číslo:")
  17.         var seventh = reader.nextDouble()
  18.     println("Zadaj ôsme číslo:")
  19.         var eight = reader.nextDouble()
  20.     println("Zadaj deviate číslo:")
  21.         var ninth = reader.nextDouble()
  22.         print("vyber operáciu (+, -, *, /): ")             //zadáme operáciu
  23.         val operator = reader.next()[0]
  24.         val result: Double
  25.         when (operator) {
  26.             '+' -> result = first + second + third + fourth + fifth + sixth + seventh + eight + ninth
  27.             '-' -> result = first - second - third - fourth - fifth - sixth - seventh - eight - ninth           //činnosť operátora
  28.             '*' -> result = first * second * third * fourth * fifth * sixth * seventh * eight * ninth
  29.             '/' -> result = first / second / third / fourth / fifth / sixth / seventh / eight / ninth
  30.              (+, -, *, /)
  31.             else -> {
  32.                 System.out.printf("Chyba")
  33.                 return
  34.             }
  35.         }
  36.         System.out.printf("%.1f %c %.1f %c %.1f %c %.1f %c %.1f %c %.1f %c %.1f %c %.1f %c %.1f = %.1f", first, operator, second, operator, third, operator, fourth, operator, fifth, operator, sixth, operator, seventh, operator, eight, operator, ninth, result)
  37.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top