Am working on a problem, basic code is shown below, takes 4 possible inputs from the user, and produces a response based on which one is input. However I need to add a test to validate that the only 1 of the 4 possible answers has been input.
I know how I could compare 2 of the 4 inputs however not all 4 at once, can someone give me an idea? Would prefer to figure out the actual code myself but a pointer in the right direction would be beneficial.
So to clarify How to - If input is anything except "Bill, Circular, Postcard or Letter" produce Error Message X
System.out.println("What type of Letter has been received?");
System.out.println("Bill, Circular, Postcard or Letter");
String Letter = kybd.nextLine();
{
if (Letter.equalsIgnoreCase("Bill"))
{
System.out.println("Bills must be paid");
}
else if (Letter.equalsIgnoreCase("Circular"))
{
System.out.println("Circulars are thrown away");
}
else if (Letter.equalsIgnoreCase("Postcard"))
{
System.out.println("Postcards are put on the wall");
}
else if (Letter.equalsIgnoreCase("Letter"))
{
System.out.println("Personal letters are read and have replies written for them");
}
}
if(a && b && c)is valid, as well asif(a || b || c)