Simple calculator
Create a simple calculator. Your program should:
- Prompt the user to enter the first number
- Prompt the user to enter the second number
- Prompt the user to enter an operation (
+
,-
,*
, or/
) - Output the solution, or tell the user they entered an invalid operation.
Here's some code snippets to help you get started:
// To create a scanner:
Scanner scan = new Scanner(System.in);
// To read a string from the user:
String exampleString = scan.nextLine();
// To convert a string to a double value
double exampleDouble = Double.parseDouble(exampleString);
// Check if aString equals the text "test". Substitute this code
// in for the "condition" below in the if statement
aString.equals("test")
// A simple if statement
if (condition) {
// If condition was true
} else {
// If condition was false
}