Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Filip Tatarka 3.AI
- import java.util.*
- fun main(args: Array<String>) {
- val reader = Scanner(System.`in`)
- print("Zadaj prvé čslo: ")
- val first = reader.nextDouble()
- println("Zadaj druhé číslo:")
- var second = reader.nextDouble()
- println("Zadaj tretie číslo:")
- var third = reader.nextDouble()
- println("Zadaj štvrté číslo:")
- var fourth = reader.nextDouble()
- println("Zadaj piate číslo:")
- var fifth = reader.nextDouble()
- println("Zadaj šieste číslo:")
- var sixth = reader.nextDouble()
- println("Zadaj siedme číslo:")
- var seventh = reader.nextDouble()
- println("Zadaj ôsme číslo:")
- var eight = reader.nextDouble()
- println("Zadaj deviate číslo:")
- var ninth = reader.nextDouble()
- print("vyber si operáciu (+, -, *, /): ")
- val operator = reader.next()[0]
- val result: Double
- when (operator) {
- '+' -> result = first + second + third + fourth + fifth + sixth + seventh + eight + ninth
- '-' -> result = first - second - third - fourth - fifth - sixth - seventh - eight - ninth
- '*' -> result = first * second * third * fourth * fifth * sixth * seventh * eight * ninth
- '/' -> result = first / second / third / fourth / fifth / sixth / seventh / eight / ninth
- else -> {
- System.out.printf("Error! operator is not correct")
- return
- }
- }
- 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)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement