Hey guys!
I have a school project and I cant figure out the coding to make it work correctly. This is what I am supposed to do:
Write a class with a main() method and two static methods. Your program should prompt the user for an integer that is no longer than five digits and no shorter than two digits. Your program should print out to the screen the integer written out as words. This should loop until the user enters the integer 0. For example:
What is your integer? 475
Your integer 475 is written out as four seven five.
What is your integer? 4755743
Your integer 4755743 is not between two and five digits in length.
What is your integer? 4
Your integer 4 is not between two and five digits in length.
What is your integer? 0
Quitting. Thank you for playing.
I currently have this but I dont think its correct:
import java.util.Scanner;
public class Project2 {
//Engine that runs main program.
public static void main(String... Args){
//Prompts user to enter two to five random integers.
Scanner input = new Scanner(System.in);
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 (true) {
validateLength(userNumber);
}
}
public static boolean validateLength(int userNumber); {
if (userNumber < 2); {
System.out.print("The number you entered is too short!");
return false;}
else if (userNumber > 5);{
System.out.print("The number you entered is too long!");
return false;}
else
return true;
}
}