Compare commits
1 Commits
VScode-Ver
...
dc4294ea5e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dc4294ea5e |
@@ -3,10 +3,11 @@ package com.company;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Main {
|
||||
@SuppressWarnings("InfiniteLoopStatement")
|
||||
public static void main(String[] args)
|
||||
{
|
||||
Scanner in = new Scanner(System.in);
|
||||
while (true) {
|
||||
while(true) {
|
||||
Scanner in = new Scanner(System.in);
|
||||
print("Enter first number: ");
|
||||
String num1 = in.nextLine();
|
||||
print("please enter second number");
|
||||
@@ -17,27 +18,23 @@ public class Main {
|
||||
String op = in.nextLine();
|
||||
|
||||
switch (op) {
|
||||
case "+": {
|
||||
case "+" -> {
|
||||
int total = add(num1, num2);
|
||||
System.out.println(total);
|
||||
}
|
||||
case "-": {
|
||||
case "-" -> {
|
||||
int total = sub(num1, num2);
|
||||
System.out.println(total);
|
||||
}
|
||||
case "x": {
|
||||
case "*", "x" -> {
|
||||
int total = mul(num1, num2);
|
||||
System.out.println(total);
|
||||
}
|
||||
case "*": {
|
||||
int total = mul(num1, num2);
|
||||
System.out.println(total);
|
||||
}
|
||||
case "/": {
|
||||
case "/" -> {
|
||||
int total = div(num1, num2);
|
||||
System.out.println(total);
|
||||
}
|
||||
default: print("Unexpected value: " + op + " ...restarting program");
|
||||
default -> print("Unexpected value: " + op + " ...restarting program");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user