From 3807b7818f8b7a00f7dc5ce0eae9313df1684316 Mon Sep 17 00:00:00 2001 From: dima Date: Wed, 13 Nov 2024 19:47:30 +0300 Subject: [PATCH] fixes --- src/Main.java | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/Main.java b/src/Main.java index 0a97527..79b2343 100644 --- a/src/Main.java +++ b/src/Main.java @@ -4,22 +4,19 @@ 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) { + + public static final String OPERATION_ADD = "+"; + public static final String OPERATION_SUBTRACT = "-"; + public static final String OPERATION_MULTIPLY = "*"; + public static final String OPERATION_DIVIDE = ":"; + public static final String OPERATION_POWER = "^"; + + 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 = "^"; - - if( operation != a && operation != b && operation != c && operation != d && operation != e) { - System.out.println("ошибка"); - - } if (":".equals(operation)) { if (number2 != 0) { @@ -29,7 +26,9 @@ public class Main { System.out.println("На 0 делить нельзя"); } } - + if (operation.equals(OPERATION_ADD) && operation.equals(OPERATION_SUBTRACT) && operation.equals(OPERATION_MULTIPLY) && operation.equals(OPERATION_DIVIDE) && operation.equals( OPERATION_POWER)) { + System.out.println("ошибка"); + } if ("+".equals(operation)) { float addition = number1 + number2; System.out.println(addition);