/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package numberwords1v1;
import java.io.*;
/**
*
*
*/
public class NumberWords1V1 {
/**
* @param args the command line arguments
*/
public static void main (String args []) throws IOException {
BufferedReader br = new BufferedReader (new InputStreamReader (System.in)); //user input
System.out.println("Numbers to Words (1-999 Edition)");
System.out.println("================================ ");
int tryAgain = 1; //will initiate the first do-while loop of the program.
do {
System.out.println();
System.out.println("Input a number (1-999) and this program will repeat it to you with words.");
double numInput = Integer.parseInt(br.readLine()); //user inputs number
System.out.println();
int error = 1; //will initiate error check
do {
if (numInput < 1 || numInput > 999) {//if the user enters an invalid number
System.out.println("Invalid number. Enter a number between 1 and 999.");
numInput = Integer.parseInt(br.readLine()); //user must re-enter a number if they entered an invalid one
System.out.println();}
else {
error = 0;} //will end error loop if the number is correct
} while (error == 1);
System.out.println();
double hundredsDigit = Math.floor(numInput);
double tensDigit = Math.floor((numInput % 100) / 10);
double onesDigit = numInput % 10;
System.out.print("Your number in words is: " );
if ((numInput >= 1) && (numInput <= 9)) {//will initiate the ones subroutine
ones(onesDigit);}
if ((numInput >= 10) && (numInput <= 19)) {//will initiate the teens subroutine
teens(numInput);}
if ((numInput >= 20) && (numInput <= 99)) {//will initiate the tens and ones subroutine
tens(tensDigit);
System.out.print(" "); //puts a space between the tens and ones
ones(onesDigit);}
if ((numInput >= 100) && (numInput <= 999)) {//will initiate the hundreds, tens and ones subroutine
hundreds(hundredsDigit);
System.out.print(" "); //puts a space between the hundreds and tens
tens(tensDigit);
System.out.print(" "); //puts a space between the tens and ones
ones(onesDigit);
}
System.out.println();
System.out.println();
System.out.println("Press 1 to try again.");
tryAgain = Integer.parseInt(br.readLine()); //user decides to try again
System.out.println();
} while (tryAgain == 1); //will repeat program if user chooses to enter another number
} //closes main body
public static void hundreds(double hundredsDigit){
} //closes hundreds method
public static void tens(double tensDigit){
} //closes tens method
public static void teens(double numInput){
} //closes teens method
public static void ones(double onesDigit) {
}//closes ones method
}