to accept Customer Code No , Customer Name and Total Bill Amount
of (n) number of customer
n is accepted at runtime
Also after accepting print the data as per format given below
Customer
Code No Name Total Bill Amount
----------------------------------------------------------------
----------------------------------------------------------------
Grand Total
Print the Grand total in word format as
If Grand total is 8769
Print as EIGHT SEVEN SIX NINE
till now i have done the following code but i am struck with the looping where i have to take n users...
if anyone can plz modify he code and tell me...
Expand|Select|Wrap|Line Numbers
- class customer
- {
- private:
- int ncust;
- int *codeno;
- char **name;
- int *tbill;
- char name[20];
- int grandttl;
- public:
- void ct_accept (void);
- void ct_print (void);
- };
- //Function
- #include<iostream.h>
- #include<string.h>
- #include <iomanip.h>
- void customer::ct_accept(void)
- {
- cout<<"Enter Customer Code no.: ";
- cin>>codeno;cin.get();
- cout<<"Enter Customer Name: ";
- cin.getline(name,20);
- cout<<"Enter Customer Grand Total: ";
- cin>>grandttl;
- }
- void customer::ct_print(void)
- {
- /*int num;
- cout<<"Enter the Number of Customers: ";
- cin>>num;*/
- cout<<endl << "Customer Code No. ";
- cout<<"Customer Name ";
- cout<<"Grand Total ";
- cout << endl;
- for(int i=0;i<=62;i++)
- {
- cout<<"-";
- }
- cout<<endl;
- cout<<setw(10) << codeno;
- cout<<setw(30) << name;
- cout<<setw(20) << grandttl;
- cout<<endl;
- for(i=0;i<=62;i++)
- {
- cout<<"-";
- }
- cout<<endl;
- cout<<"Grand Total: ";
- int word,rem, store[100000];
- if(grandttl==0)
- {
- cout<<"zero";
- }
- else
- {
- while(word!=0)
- {
- word=grandttl/10;
- rem=grandttl%10;
- store[i]=rem;
- i++;
- grandttl=word;
- }
- i--;
- for(i;i>=0;i--)
- {
- store[i];
- switch(store[i])
- {
- case 0:
- cout<<"zero ";
- break;
- case 1:
- cout<<"one ";
- break;
- case 2:
- cout<<"two ";
- break;
- case 3:
- cout<<"three ";
- break;
- case 4:
- cout<<"four ";
- break;
- case 5:
- cout<<"five ";
- break;
- case 6:
- cout<<"six ";
- break;
- case 7:
- cout<<"seven ";
- break;
- case 8:
- cout<<"eight ";
- break;
- case 9:
- cout<<"nine ";
- break;
- }
- }
- }
- }
- main()
- {
- customer rec;
- rec.ct_accept();
- rec.ct_print();
- cin.get();
- cin.get();
- return 0;
- }