This program is supposed to be a basic calculator that takes two double inputs and then prompts for the user to type a string with a corresponding mathematical operator. For some reason my basic calculator will not return a value after the user has input a String corresponding to the menu.
import java.util.Scanner;
public class Assignment3 {
public static void main (String[] args)
{
String operator = "";
double userInputOne;
double userInputTwo;
double output = -.00001;
String comparison = "";
Scanner scan = new Scanner(System.in);
System.out.println("Enter the first number of your calculation:");
userInputOne = scan.nextDouble();
System.out.println("Enter the second number of your calculation:");
userInputTwo = scan.nextDouble();
System.out.println("Type in one direction under Calculator Options:");
System.out.println("Add, Subtract, Multiply, Divide, Mod");
System.out.println("Compare");
System.out.println("Print Numbers");
System.out.println("Quit");
Scanner scanTwo = new Scanner(System.in);
operator = scanTwo.nextLine();
if (operator == "Add")
{
output = userInputOne + userInputTwo;
}else if (operator == "Subtract"){
output = userInputOne - userInputTwo;
}else if (operator == "Multiply"){
output = userInputOne * userInputTwo;
}else if (operator == "Divide"){
output = userInputOne / userInputTwo;
}else if (operator == "Mod"){
output = userInputOne % userInputTwo;
}else if (operator == "Compare"){
if(userInputOne == userInputTwo){
comparison = (userInputOne + " Is equal to " + userInputTwo);
System.out.println(comparison);
}else if (userInputOne > userInputTwo){
comparison = (userInputOne + " Is greater than " + userInputTwo);
System.out.println(comparison);
}else if (userInputOne < userInputTwo){
comparison = (userInputOne + " Is less than " + userInputTwo);
System.out.println(comparison);
}
}else if (operator == "Print Numbers"){
comparison = userInputOne + " " + userInputTwo;
System.out.println(comparison);
}else if (operator == "Quit"){
System.exit(0);
}
if (output != -.00001){
System.out.println(output);
}
}
}