This question already has an answer here:
- How do I compare strings in Java? 23 answers
I dont see why my if statement is being skipped (im new) My code is also not waiting for my reply with ReplyS (right before the if statement)
do {
System.out.println("What is your first number? ");
Num1 = Scan.nextInt();
System.out.println("Thanks! What is your second number? ");
Num2 = Scan.nextInt();
newNumber = Answer(Num1, Num2);
System.out.println("After adding your numbers up I got " + newNumber);
System.out.println("Would you like to do something with the NEW number? ");
ReplyS = Scan.nextLine();
if(ReplyS == "y" ) { //asks the user if the want to do math with new number
System.out.println("Would you like to/n 1. Multiply with a new number? /n 2. Divide with a new number? /n "
+ "3. Dont choose 3!! ");
ReplyI = Scan.nextInt();
if(ReplyI == 1) {
System.out.println("What is the new number to multiply with " + newNumber);
ReplyI = Scan.nextInt();
Num4 = newNumber*ReplyI;
System.out.println("After multiplying your numbers I got " + Num4);
}
}
System.out.println("would you like to start from the beggining? ");
reRun = Scan.nextLine();
}
while (reRun == "y");
}
Aucun commentaire:
Enregistrer un commentaire