Change over to Intellij

using older version of switch
This commit is contained in:
Chris's Razer Blade 2021-01-08 17:48:20 -05:00
parent 1dad68ed79
commit dc4294ea5e
1 changed files with 8 additions and 11 deletions

View File

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