I am a beginner to programming (literally two days new), and I am having an issue. I am trying to make a VERY basic calculator, where the user inputs the first number, the operation (only +, -, *, and /), and then the second number. I'm having trouble getting the input of the operation to determine what the answer will be with the if statements, so can someone please explain it using very simple terminology?
package learn;
import java.util.Scanner;
class calculator{
public static void main(String args[]){
Scanner input = new Scanner(System.in);
double termOne, operation, termTwo, answer;
System.out.println("Enter first term: ");
termOne = input.nextDouble();
System.out.println("Enter operation (Valid operations are : ");
operation = input.nextDouble();
System.out.println("Etner second term: ");
termTwo = input.nextDouble();
if (operation == add) {
answer = termOne + termTwo;
System.out.println(answer);
} else if (operation == subtract) {
answer = termOne - termTwo;
System.out.println(answer);
} else if (operation == divide) {
answer = termOne / termTwo;
System.out.println(answer);
} else (operation == multiply) {
answer = termOne * termTwo;
System.out.println(answer);
}
}
}