i have to write a program that takes input from the user and displays a simulated check we have to write the dollar amount in words and i cant figure out how to go about doing that. this is my code so far.

``````//*******************************************************
//			Include Files
//*******************************************************
#include<iostream>
#include<iomanip>
#include<string>
#include<cstdlib>
using namespace std;

//**********************************************************
//		Main line
//***********************************************************
int main()
{
string date;
string name;
double amount;
double nAmount=0.0;

cout << "Enter the date : ";
cin >> date;

cout << "Enter payee name : ";
cin.ignore();
getline(cin,name);

cout << "Enter the amount of the check : ";
cin >> amount;

while(amount>999.99 || amount <0)
{
cout << "Enter amunt greater than zero and less than \$999.99 ";
cin >> amount;
}

cout << setprecision(2) << fixed;

}``````

If you use the Site Search box up above, with the terms "numbers to words" you'll find this is a common problem (we teachers love this sort of stuff!)

The first thing you have to do is be able to break a number into the digits (thousands, hundreds, tens, ones, and the change). Then you have to use some branching to convert a given number value at a given decimal position into the correct words.

Say the number is 1563.50. You will have to output "one thousand five hundred sixty three and ...." (not sure what you're asked to do with the cents.) The trickiest part is dealing with the 10s values, and the teens.

Start with the number breakdown. Get that working, then start on writing out the numbers. Begin with just handling 2 digits; when that works, you should be able to easily scale up to larger values.