So i am trying to make a simple program that uses a user input which will be a letter and number and make the program read it as a number so at the end the numbers get added. Let me give an example. If the user inputs A1 i want the program to read it as 100 and A2 as 90 for example. At the end I want the program to add these values and give the user and answer. This is what i have:
public class LCCalcMain {
public static void main(String[] args){
Scanner input = new Scanner(System.in);
String input1, input2, answer;
System.out.println("1st result");
input1 = input.nextLine();
input1 = System.out.println("2nd result");
input2 = input.nextLine();
int A1, A2, B1;
A1 = 100;
A2 = 90;
B1 = 85;
answer = input1 + input2;
System.out.println(answer);
}
}
So i want them to enter like A1 and my program will read it as 100. So i can easily add everything at the end and give them an answer. Thanks for your help.
You can just do an if/else case per input: