switch and math problem issues
I'm new to java and have a project that requires me to make a math quiz for an individual. its starts be having the individual choose between: addition(+), sub(-), mult(*), and div(/). from there there determine whether the user wants random integers of 1 or 2 decimal places.
Not sure how to use the switch in this case, please help.
Re: switch and math problem issues
Perhaps something like this.
Code :
import java.util.Scanner;
public class ReadChar {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int decimal;
switch (s.next().charAt(0)) {
case '/':
case '*':
decimal = 2;
break;
default:
decimal = 1;
break;
}
}
}