From 66ab37114a425e7ee114994dd01777170e04ba87 Mon Sep 17 00:00:00 2001 From: dima Date: Mon, 4 Nov 2024 21:37:55 +0300 Subject: [PATCH] fixes --- src/Main.java | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/Main.java b/src/Main.java index 5dbd8ac..44ed138 100644 --- a/src/Main.java +++ b/src/Main.java @@ -8,35 +8,33 @@ public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); - int number1 = scanner.nextInt(); + float number1 = scanner.nextFloat(); String operation = scanner.next(); - int number2 = scanner.nextInt(); + float number2 = scanner.nextFloat(); System.out.print("Ответ:"); if (":".equals(operation)) { if (number2 != 0) { - float division = (float) number1 / (float) number2; + float division = number1 / number2; System.out.println(division); } else { System.out.println("На 0 делить нельзя"); } } - { - if ("+".equals(operation)) { - int addition = number1 + number2; - System.out.println(addition); - } + if ("+".equals(operation)) { + float addition = number1 + number2; + System.out.println(addition); + } - if ("-".equals(operation)) { - int subtraction = number1 - number2; - System.out.println(subtraction); - } + if ("-".equals(operation)) { + float subtraction = number1 - number2; + System.out.println(subtraction); + } - if ("*".equals(operation)) { - int multiplication = number1 * number2; - System.out.println(multiplication); - } + if ("*".equals(operation)) { + float multiplication = number1 * number2; + System.out.println(multiplication); } } } \ No newline at end of file