So this little program I made is supposed to ask you to enter a number.. it can be any random number that ends with 4. For this example lets use 1234.
Then it prompts you to enter the second number... This one has to be exactly 4.
What it does is it takes your first input and uses the modulus operator to find the remainder of 1234 which is 4.
Then it takes the remainder(4) and compares it with your second input(4)...
If the two match then it should display the message dialog box that says "you are good to go".
Now this is where my problem is.. it does not display any message dialog box like it should (this gives me the impression that the IF statement is false, but it can't be false... I think).
Please help me get through this little bit. Thanks in advance!
import javax.swing.JOptionPane; import javax.swing.JFrame; public class deksels { public static void main(String[] args) throws Exception { //Declaration of strings String inputOne; String inputTwo; inputOne=JOptionPane.showInputDialog("Please enter the first number: "); inputTwo=JOptionPane.showInputDialog("Please verify the second number: "); int copyOne=Integer.parseInt(inputOne);//this converts the first input string into an integer int done= copyOne%10;//this is the modulus to retrieve the remainder of the first input String doneAgain=Integer.toString(done);//this converts the first input back from integer to string //I believe the following code is where my problem is but i just cant figure out where i messed up if(doneAgain+inputTwo=="44")//this is the if condition, assuming your first input was 1234 and your second input is 4 { JOptionPane.showMessageDialog(null, "You are good to go!", "number game",JOptionPane.INFORMATION_MESSAGE);//if the statement is true then a message dialog is displayed } { System.exit(0);//exits the system } } }