Here is the code for my simple calculator:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>
package calculator_1;
import java.util.Scanner;
public class apples {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Calculator");
System.out.println("Enter a number");
int number1 = scan.nextInt();
System.out.println("Enter a number");
int number2 = scan.nextInt();
// doing math with numbers
int add = number1 + number2;
int sub = number1 - number2;
int times = number1 * number2;
int divide = number1 / number2;
//choosing operation to use, if statements.
System.out.println("What operation do you want to use?: add, sub, times, divide");
Scanner opy = new Scanner(System.in);
String operator = opy.nextLine();
if (operator == "add")
{
System.out.println(" Add: " + add);
}
if (operator == "sub")
{
System.out.println(" Sub: " + sub);
}
if (operator == "times")
{
System.out.println(" Times: " + times);
}
if (operator == "divide")
{
System.out.println(" Divide: " + divide);
}
}
}
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>
My code seems to work with allowing me to enter my two numbers but the problems exist when it asks me what order of operation I want to apply to my two numbers with the prompt working but when I enter my response like "add" for example, nothing happens, please help.
Thanks for your help
Jesse....