This is just a part of a program
When my code asks me
Enter diamond size ("short", "average", or "tall"):
how do i make it so that if i don't put anything and press enter it asks me exactly same questions again??
i tried putting
input.length() == 0 or input.equals("") or input == null but none of them seems to work
import java.util.Scanner;
public class Pattern
{
public static void main(String[] args)
{
Scanner kb = new Scanner(System.in);
String input;
String character;
do
{
System.out.print("Enter diamond size (\"short\", \"average\",");
System.out.print(" or \"tall\"): ");
input = kb.next().toLowerCase();
}
while (checkSize(input) == -1 || input.length() == 0);
do
{
System.out.print("Enter pattern character: ");
character = kb.next();
}
while (character.length() > 1);
char ch = character.charAt(0);
displayPattern(checkSize(input), ch);
}
public static int checkSize(String size)
{
if (size.equals("short"))
{
return 6;
}
else if (size.equals("average"))
{
return 12;
}
else if (size.equals("tall"))
{
return 22;
}
return -1;
}