From 8f9ba6e1f6fc052290d3848f373cf0364e7ff82e Mon Sep 17 00:00:00 2001 From: dima Date: Wed, 13 Nov 2024 17:09:55 +0300 Subject: [PATCH] fixes --- src/Main.java | 82 +++++++++++++++++++++++++-------------------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/src/Main.java b/src/Main.java index eeeb6d6..0a97527 100644 --- a/src/Main.java +++ b/src/Main.java @@ -4,51 +4,51 @@ import java.util.Scanner; //TIP To Run code, press or // click the icon in the gutter. public class Main { - - public static void main(String[] args) { - - Scanner scanner = new Scanner(System.in); - float number1 = scanner.nextFloat(); - String operation = scanner.next(); - float number2 = scanner.nextFloat(); + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + float number1 = scanner.nextFloat(); + String operation = scanner.next(); + float number2 = scanner.nextFloat(); System.out.print("Ответ:"); - String a = "+"; - String b = "-"; - String c = "*"; - String d = ":"; - String e = "^"; + String a = "+"; + String b = "-"; + String c = "*"; + String d = ":"; + String e = "^"; + if( operation != a && operation != b && operation != c && operation != d && operation != e) { + System.out.println("ошибка"); - if (operation != a && operation != b && operation != c && operation != d && operation != e) { - System.out.println("ошибка"); - } + } if (":".equals(operation)) { - if (number2 != 0) { - float division = number1 / number2; - System.out.println(division); - } else { - System.out.println("На 0 делить нельзя"); - } - } - - if ("+".equals(operation)) { - float addition = number1 + number2; - System.out.println(addition); - } - - if ("-".equals(operation)) { - float subtraction = number1 - number2; - System.out.println(subtraction); - } - - if ("*".equals(operation)) { - float multiplication = number1 * number2; - System.out.println(multiplication); - } - if ("^".equals(operation)) { - double power = Math.pow(number1, number2); - System.out.println(power); + if (number2 != 0) { + float division = number1 / number2; + System.out.println(division); + } else { + System.out.println("На 0 делить нельзя"); } } -} \ No newline at end of file + + if ("+".equals(operation)) { + float addition = number1 + number2; + System.out.println(addition); + } + + if ("-".equals(operation)) { + float subtraction = number1 - number2; + System.out.println(subtraction); + } + + if ("*".equals(operation)) { + float multiplication = number1 * number2; + System.out.println(multiplication); + } + if ("^".equals(operation)) { + double power = Math.pow(number1, number2); + System.out.println(power); + + + } +} + }