This commit is contained in:
dima 2024-11-13 19:47:30 +03:00
parent 8f9ba6e1f6
commit 3807b7818f

View File

@ -4,22 +4,19 @@ import java.util.Scanner;
//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
// click the <icon src="AllIcons.Actions.Execute"/> 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);