0

My code is fairly long so I only have a snippet of it below. My program is an elapsed time calculator, and at one portion, the application prompts the user for am or pm. My intentions are for the application to end if the user enters anything other than am or pm, however, anything entered by the user, including the actual string of PM and AM, causes the "Please try again" prompt to print. Are there any methods similar to != that are compatible with string, or things to do that could possible solve my issue?

Also I want to be able to implement the equalsIgnoreCase method in somehow, for if the user was to enter Am, am, AM, etc..

if (timeOfDay != PM || timeOfDay != AM){
            System.out.println("\"AM\" or \"PM\" was not specified. Please try again.");
            System.exit(0);
        }

0 Answers0