I'm a freshman computer science major in college and I am completely new to all of this stuff. We are currently using java and are on our first homework where we have to make a combat calculator for a text based game. My problem is in the if else statements that I have, where the print line statements won't print out when I run the program.
userInput = input.next();
int action1 = 1;
action1 = input.nextInt();
int action2 = 2;
action2 = input.nextInt();
int action3 = 3;
action3 = input.nextInt();
int action4 = 4;
action4 = input.nextInt();
if (userInput == action1){
System.out.println("You strike the goblin with your sword for 12 damage.");
}
else if (userInput.equals(action2)){
System.out.println("You cast the weaken spell on the goblin.");
}
else if (userInput.equals(action3)){
System.out.println("You focus and charge your magic power.");
}
else if (userInput.equals(action4)){
System.out.println("You run away!");
}
}
I also don't know how to put codes properly in this website so sorry if it's a little hard to understand. But anyway, what am I doing wrong to where my output for the if...else statements won't print?