fixes
This commit is contained in:
parent
8f9ba6e1f6
commit
3807b7818f
@ -4,22 +4,19 @@ import java.util.Scanner;
|
|||||||
//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
|
//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
|
||||||
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
|
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
|
||||||
public class Main {
|
public class Main {
|
||||||
|
|
||||||
|
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) {
|
public static void main(String[] args) {
|
||||||
Scanner scanner = new Scanner(System.in);
|
Scanner scanner = new Scanner(System.in);
|
||||||
float number1 = scanner.nextFloat();
|
float number1 = scanner.nextFloat();
|
||||||
String operation = scanner.next();
|
String operation = scanner.next();
|
||||||
float number2 = scanner.nextFloat();
|
float number2 = scanner.nextFloat();
|
||||||
System.out.print("Ответ:");
|
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 (":".equals(operation)) {
|
||||||
if (number2 != 0) {
|
if (number2 != 0) {
|
||||||
@ -29,7 +26,9 @@ public class Main {
|
|||||||
System.out.println("На 0 делить нельзя");
|
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)) {
|
if ("+".equals(operation)) {
|
||||||
float addition = number1 + number2;
|
float addition = number1 + number2;
|
||||||
System.out.println(addition);
|
System.out.println(addition);
|
||||||
|
Loading…
Reference in New Issue
Block a user