all right this is what I have:
import java.util.Scanner;
public class Project2 {
//Engine that runs main program.
public static void main(String... Args){
Scanner input = new Scanner(System.in);
//Prompts user to enter two to five random integers.
System.out.println("Enter a number that has two to five digits! " + " Enter 0 to exit application. ");
System.out.print(" What is you integer? ");
int userNumber = input.nextInt();
while (userNumber >= 0) {
if (userNumber == 0) {
System.out.print( "Thank you for playing! " + "Good bye! ");
break; }
else if (userNumber != 0)
if(validateLength(userNumber) == true){
System.out.print(convertIntegerToWords(userNumber) + convertIntegerToWords(userNumber) + convertIntegerToWords(userNumber));
}
}
}
public static boolean validateLength(int userNum) {
String userNumber = "" + userNum;
if (userNumber.length() < 2) {
System.out.print("The number you entered is too short!");
return false;
}
else if (userNumber.length() > 5) {
System.out.print("The number you entered is too long!");
return false;}
else
return true;
}
public static String convertIntegerToWords(int numWord) {
String numWordString = "";
switch (numWord) {
case 0: numWordString = "Zero"; break;
case 1: numWordString = "One"; break;
case 2: numWordString = "Two"; break;
case 3: numWordString = "Three"; break;
case 4: numWordString = "Four"; break;
case 5: numWordString = "Five"; break;
case 6: numWordString = "Six"; break;
case 7: numWordString = "Seven"; break;
case 8: numWordString = "Eight"; break;
case 9: numWordString = "Nine"; break;
}
return numWordString;
}
}
But i am still having loop problems when I in put less than two or more than five numbers. Also If I input 2-5 integers it get stuck and doesnt do anything. Please help!!!