I am writing a program for class in which I analyze different product codes entered. It is pretty simple but I am having a problem. I am trying to end a loop if a user enters an "E" or "e". However, it does not end the loop at all. This is at the end of a while statement so setting loop to false should end it and it doesn't even output the totals either so I have messed something up. Code is a string type.
// Prompt the user for another company code or exit
System.out.print("Enter the company code or type 'e' to exit: ");
// Input the user's company code
code = scan.nextLine();
// Check to see if the user wants to exit
if (code == "e" || code == "E") {
// Output final statistics
System.out.print("Total valid codes: " + valid + "/n");
System.out.print("Total banned codes: " + banned);
// End the loop
loop = false;
}
Any ideas? Thanks!