fixes
parent
bf305d907e
commit
8f9ba6e1f6
|
@ -4,51 +4,51 @@ 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 void main(String[] args) {
|
||||||
public static void main(String[] args) {
|
Scanner scanner = new Scanner(System.in);
|
||||||
|
float number1 = scanner.nextFloat();
|
||||||
Scanner scanner = new Scanner(System.in);
|
String operation = scanner.next();
|
||||||
float number1 = scanner.nextFloat();
|
float number2 = scanner.nextFloat();
|
||||||
String operation = scanner.next();
|
|
||||||
float number2 = scanner.nextFloat();
|
|
||||||
System.out.print("Ответ:");
|
System.out.print("Ответ:");
|
||||||
String a = "+";
|
String a = "+";
|
||||||
String b = "-";
|
String b = "-";
|
||||||
String c = "*";
|
String c = "*";
|
||||||
String d = ":";
|
String d = ":";
|
||||||
String e = "^";
|
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 (":".equals(operation)) {
|
||||||
if (number2 != 0) {
|
if (number2 != 0) {
|
||||||
float division = number1 / number2;
|
float division = number1 / number2;
|
||||||
System.out.println(division);
|
System.out.println(division);
|
||||||
} else {
|
} else {
|
||||||
System.out.println("На 0 делить нельзя");
|
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 ("+".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);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue