BANK CHEQUE WRITER

Write your question here.


//write an algorithm for this program and optimize the
entire procedural function using c++ constructs
//Do not change the control structures used
//Make the program interactive(user friendly)
#include <iostream>
#include <ostream>
#include <cstdio>
#include <string>

using namespace std;

int main()
{
string a1[22]={"zero","One","Two","Three","Four","Five","Six","Seven","Eight","Nine"
,"Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen",
"Eighteen","Nineteen","Twenty"};
string a2[22]={"Zero","Ten","Twenty","Thirty","Forty","Fifty","Sixty","Seventy",
"Eighty","Ninety"};
string afinal;
string hund;
string tenn;
string munit;
int myvalue=94;
string cedi= "Ghana Cedis";
int my100;
int my10, my1;
int my10s;
my100= myvalue/100;
cout<<"my100 = "<<my100<<endl;
hund= a1[my100]+ " " + " Hundred and ";
cout<< "my100 = "<<a1[my100] + " Hundred and "<<endl;
my10= myvalue - (my100*100);
my10s =(myvalue -(my100*100))/10;
cout<< "my10 = "<<my10s<<endl;
cout<< "my10 = "<<a1[my10s]<<endl;
my1= my10- (my10s*10);
if(my100 >= 0)
{
if(my10<=20)
{
tenn =a1[my10]+ " "+ cedi;
}
else{
if(my1>0)
{
tenn= a2[my10s] + " ";
}
else{
tenn=a2[my10s] + " " + cedi;
}
}
}
if(my1>0)
{
munit="-" +a1[my1] +cedi;

}
else{
munit = " ";
}
cout<< "my1 = "<<my1<<a1[my1]<<endl;
cout<< endl;
if( my100==0)
{
hund =" ";
}
afinal= hund +" "+ tenn +munit;
cout<< myvalue <<endl;
cout<< afinal <<endl;
return 0;
}
Please use code tags. What exactly is your problem?
Create a class or a struct called cheque , make a variable called const char * name , double currency , double dollar. That will be a start. Then create a friend method overload for the operator << of ofstream and called that method printCheque. Create another method that convert double value to currency and dollar called it addToAccount. This method will increment the dollar and currency. Then you can ask to the console what is your name then add amount and also output press ok to submit then in the main when you exit the loop you call the print method. That should do.
Topic archived. No new replies allowed.