fixes
parent
5745de5bab
commit
f2b2013249
|
@ -1,3 +1,4 @@
|
||||||
|
import javax.swing.*;
|
||||||
import java.util.Scanner;
|
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
|
||||||
|
@ -6,34 +7,36 @@ public class Main {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
Scanner a = new Scanner(System.in);
|
Scanner scanner = new Scanner(System.in);
|
||||||
int number1 = a.nextInt();
|
int number1 = scanner.nextInt();
|
||||||
String sing = a.next();
|
String operation = scanner.next();
|
||||||
int number2 = a.nextInt();
|
int number2 = scanner.nextInt();
|
||||||
System.out.print("Ответ:");
|
System.out.print("Ответ:");
|
||||||
|
|
||||||
if (":" .equals(sing) && number2 != 0 ) {
|
if (":".equals(operation)) {
|
||||||
float sum = (float) number1 / (float) number2;
|
if (number2 != 0) {
|
||||||
System.out.println(sum);
|
float division = (float) number1 / (float) number2;
|
||||||
|
System.out.println(division);
|
||||||
|
} else {
|
||||||
|
System.out.println("На 0 делить нельзя");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
|
||||||
if (":".equals(sing) && number2 == 0) {
|
if ("+".equals(operation)) {
|
||||||
System.out.println("на ноль делить нельзя");
|
int addition = number1 + number2;
|
||||||
}
|
System.out.println(addition);
|
||||||
|
}
|
||||||
|
|
||||||
if ("+" .equals(sing)) {
|
if ("-".equals(operation)) {
|
||||||
int sum = number1 + number2;
|
int subtraction = number1 - number2;
|
||||||
System.out.println(sum);
|
System.out.println(subtraction);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("-" .equals(sing)) {
|
if ("*".equals(operation)) {
|
||||||
int sum = number1 - number2;
|
int multiplication = number1 * number2;
|
||||||
System.out.println(sum);
|
System.out.println(multiplication);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("*" .equals(sing)) {
|
|
||||||
int sum = number1 * number2;
|
|
||||||
System.out.println(sum);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue