master
dima 2024-11-04 21:37:55 +03:00
parent f2b2013249
commit 66ab37114a
1 changed files with 14 additions and 16 deletions

View File

@ -8,35 +8,33 @@ public class Main {
public static void main(String[] args) { public static void main(String[] args) {
Scanner scanner = new Scanner(System.in); Scanner scanner = new Scanner(System.in);
int number1 = scanner.nextInt(); float number1 = scanner.nextFloat();
String operation = scanner.next(); String operation = scanner.next();
int number2 = scanner.nextInt(); float number2 = scanner.nextFloat();
System.out.print("Ответ:"); System.out.print("Ответ:");
if (":".equals(operation)) { if (":".equals(operation)) {
if (number2 != 0) { if (number2 != 0) {
float division = (float) number1 / (float) 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)) { if ("+".equals(operation)) {
int addition = number1 + number2; float addition = number1 + number2;
System.out.println(addition); System.out.println(addition);
} }
if ("-".equals(operation)) { if ("-".equals(operation)) {
int subtraction = number1 - number2; float subtraction = number1 - number2;
System.out.println(subtraction); System.out.println(subtraction);
} }
if ("*".equals(operation)) { if ("*".equals(operation)) {
int multiplication = number1 * number2; float multiplication = number1 * number2;
System.out.println(multiplication); System.out.println(multiplication);
}
} }
} }
} }