Ok, so first you are wanting to know how to make the program continue while invalid letters are entered?
So, you could create a WHILE Loop that checks if the values are invalid. This is an example of code doing the same thing, but with numbers instead of Strings (we cant do everything for you):
import java.util.Scanner;
public class CheckNumbersProgram
{
public static void main(String[] args)
{
//Create Scanner
Scanner scanner = new Scanner(System.in);
//Prompt User
System.out.println("Enter 4 Numbers:\n");
//Create Variables to Hold Numbers
int num1=0;
int num2=0;
int num3=0;
int num4=0;
//Set values for User's First Input
num1 = scanner.nextInt();
num2 = scanner.nextInt();
num3 = scanner.nextInt();
num4 = scanner.nextInt();
/* WHILE Loop to continue prompting user
* This WHILE Loop reads:
* If Num1 is Negative, Enter Loop, OR
* If Num2 is Negative, Enter Loop, OR
* If Num3 is Negative, Enter Loop, OR
* If Num4 is Negative, Enter Loop
* Else, Skip
*/
while(num1 < 0 || num2 < 0 || num3 < 0 || num4 < 0)
{
//Prompt User to Input New Numbers
System.out.println("Invalid Numbers Entered. Please Enter 4 New Numbers:\n");
//Set values for User's First Input
num1 = scanner.nextInt();
num2 = scanner.nextInt();
num3 = scanner.nextInt();
num4 = scanner.nextInt();
}
System.out.println("Program Finished.");
}
}
Now, as for checking the letters, instead of checking all letters, you just have to check to see if the letters are NOT the acceptable 4. So, instead of your 22 if statements, we need 4, or even 1 will do.
4 If Statements:
if(!input.equals("z"))
{...}
else if(!input.equals("x"))
{...}
else if(!input.equals("c"))
{...}
else if(!input.equals("v"))
{...}
1 If Statement:
if(!input.equals("z") || !input.equals("x") || !input.equals("c") || !input.equals("v"))
{...}