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