Skip to main content

Simple calculator

Create a simple calculator. Your program should:

  1. Prompt the user to enter the first number
  2. Prompt the user to enter the second number
  3. Prompt the user to enter an operation (+, -, *, or /)
  4. 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
}