I just started writing this basic text-based calculator in Java and I found into a problem when I ran the adding portion, when I add 2 numbers, say '9' and '9', the answer comes out to 99 instead of 18, as it should. Is it because I'm not storing integers, I'm storing the user's input as strings. Thank you, I appreciate any help. As you can probably tell, I'm rather new to coding.
import java.util.Scanner;
import java.lang.String;
public class calc {
public static void main(String[] args) throws InterruptedException {
while (true) {
Scanner in = new Scanner(System.in);
System.out.println("Type in what you would like to do: Add, Subtract, Multiply, or Divide");
String input = in.nextLine();
if (input.equalsIgnoreCase("Add")) {
System.out.println("Type in your first number:");
String add1 = in.nextLine();
System.out.println("Type in your second number");
String add2 = in.nextLine();
String added = add1 + add2;
System.out.println("Your answer is:" + added);
}
else if(input.equalsIgnoreCase("Subtract")) {
System.out.println("Type in your first number:");
}
else if(input.equalsIgnoreCase("Multiply")) {
System.out.println("Type in your first number:");
}
else if(input.equalsIgnoreCase("Divide")) {
System.out.println("Type in your first number:");
}
else {
System.out.println("This was not a valid option");
}
}
}
}