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;
public class Main {
@SuppressWarnings("InfiniteLoopStatement")
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
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");
}
}
}