Go ahead and compare, I hope mine works on your machiene like it does on mine
Code:
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
//The model.
string single[]={"zero", "one", "two", "three", "four", "five", "six", "seven",
"eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen",
"seventeen", "eighteen", "nineteen"};
string tens[]={"null", "ten", "twenty", "thirty", "fourty", "fifty", "sixty",
"seventy", "eighty", "ninty"};
string hundreds[]={"null", "one hundred", "two hundred",
"three hundred", "four hundred", "five hundred", "six hundred", "seven hundred",
"eight hundred", "nine hundred"};
int main()
{
double amount;
int subdollars;
int subcents;
cout<<"Amount: ";
cin>>amount;
cout<<endl<<endl;
double dollars;
double cents;
cents=modf(amount, &dollars)*100;
cout<<dollars<<" "<<cents<<endl;
cout<<endl<<endl;
if (dollars > 99)
{
subdollars=dollars/100;
cout<<hundreds[subdollars];
cout<<" ";
dollars=dollars-(subdollars*100);
}
if (dollars > 20)
{
subdollars=dollars/10;
cout<<tens[subdollars];
cout<<" ";
dollars=dollars-(subdollars*10);
}
if (dollars > 0 && dollars < 20)
{
subdollars=dollars;
cout<<single[subdollars];
cout<<" ";
dollars=dollars-(subdollars);
}
cout<<"dollars & ";
if (cents > 20)
{
subcents=cents/10;
cout<<tens[subcents];
cout<<" ";
cents=cents-(subcents*10);
}
if (cents > 0 && cents < 20)
{
subcents=cents;
cout<<single[subcents];
cout<<" ";
cents=cents-(subcents);
}
cout<<"cents"<<endl;
return 0;
}
Works on mine, let me know how it goes for you.