My program is to convert numbers between 0 and 100 to words. I'm not sure which strategy would be best to go about this but I would like to use math operators like modules, etc.This is what I've got so far.
package project.pkg1;
import java.util.Scanner;
public class Project1 {
public static final int MINUMUN_NUMBER = 0;
public static final int MAXIMUM_NUMBER = 100;
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
int num, x;
do{
System.out.println("Enter a number between 0 and 100: ");
num = keyboard.nextInt();
} while ((num < 0) || (num > 100));
if(num == 0)
System.out.println("zero");
if(num == 100)
System.out.println("one hundred");
I don't want to use the if(num == x) every time. My validation trap to make sure it is between 0 and 100 works fine. I'm just not sure how to approach the rest of it. This is what I can get to print:
run:
Enter a number between 0 and 100:
-1
Enter a number between 0 and 100:
101
Enter a number between 0 and 100:
34
BUILD SUCCESSFUL (total time: 23 seconds)
I need that 34 to print "thirty four" Any feedback would be greatly appreciated!