This is an assignment in my c++programming class. The assignment was to write a program that will print out a check like some department stores use when you check out. I have a problem with the program printing out 100.00 to 109.00. Its prints the written amout below the line where it is suppose to go. It only does this with the above mention amounts. Also we have to use the system date and I don't know if thats right or not either. I have a few warnings also. Any info would help greatly.This is my first class working with c++ programming.
#include <iostream.h>
#include <iomanip.h>
#include <math.h>
int main()
{const char x=20;
char h[x],t[20],o[5];
double amt;
long tamt, d1,d2,d3,d4,d5;
cout << " Input the check amount and press enter: ";
cin >> amt;
if (amt <= 1000.00)
{
tamt=amt*100;
d1=tamt%10;
d2=tamt%100/10;
d3=tamt%1000/100;
d4=tamt%10000/1000;
d5=tamt%100000/10000;
cout << "_________________________________________________ ______________________________\n\n\n"<<endl;
cout << setw(45) << (" Date %s\n",__DATE__) << endl;
cout << (" ") << endl;
cout << " Pay: " << " WalMart " << " "<<setw(7) << setiosflags(ios::fixed||ios::showpoint) << setprecision(2) << "$" << d5 << d4 << d3 << "." << d2 << d1 << endl;
cout << " " << endl;
switch(d5)
{case 1:
cout <<" One Hundred ";
break;
case 2:
cout << " Two Hundred ";
break;
case 3:
cout << " Three Hundred ";
break;
case 4:
cout << " Four Hundred ";
break;
case 5:
cout << " Five Hundred ";
break;
case 6:
cout << " Six Hundred ";
break;
case 7:
cout << " Seven Hundred ";
break;
case 8:
cout << " Eight Hundred ";
break;
case 9:
cout << " Nine Hundred ";
break;
default: cout << " " <<endl;
}
switch(d4)
{case 1:
if (d3==0)
cout << " ten ";
else if(d3==1)
cout << " eleven ";
else if(d3==2)
cout << " twelve ";
else if(d3==3)
cout << " thirteen ";
else if(d3==4)
cout << " fourteen ";
else if(d3==5)
cout << " fifteen ";
else if(d3==6)
cout << " sixteen ";
else if(d3==7)
cout << " seventeen";
else if(d3==8)
cout << " eighteen ";
else if(d3==9)
cout << " nineteen ";
break;
case 2:
cout << "Twenty-";
break;
case 3:
cout << "Thirty-";
break;
case 4:
cout << " Forty-";
break;
case 5:
cout << " Fifty-";
break;
case 6:
cout << " Sixty-";
break;
case 7:
cout << " Seventy-";
break;
case 8:
cout << " Eighty-";
break;
case 9:
cout << " Ninety-";
break;
default: cout << " " << endl;
}
switch (d3)
{
case 1:
if(d4 !=1)
cout << " One ";
break;
case 2:
if(d4 !=1)
cout << " Two ";
break;
case 3:
if(d4 !=1)
cout << " Three";
break;
case 4:
if(4 !=1)
cout << " Four ";
break;
case 5:
if(d4 !=1)
cout << " Five ";
break;
case 6:
if(d4 !=1)
cout << " Six ";
break;
case 7:
if(d4 !=1)
cout << " Seven ";
break;
case 8:
if(d4 !=1)
cout << " Eight ";
break;
case 9:
if(d4 !=1)
cout << " Nine ";
break;
default: cout << " ";
}
}
cout <<"Dollars and **************" <<d2<<d1<<"/"<<100 <<endl;
cout << "_________________________________________________ ________________" <<endl;
return 0;
}