Advertisement
CatmanIX

check out my pretty code

Dec 4th, 2012
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.70 KB | None | 0 0
  1. #include <string>
  2. #include <iostream>
  3. #include <iomanip>
  4. #include <fstream>
  5. using namespace std;
  6.  
  7. /*
  8. Name: Marshal Walker
  9. Assignment #1: Some half-assed "program" to do invoices.
  10. */
  11.  
  12. int main()
  13. {
  14.     //housekeeping
  15.     const double chargeRoomDay=189.00, chargeServiceDay=19.00;
  16.     double chargeMisc, chargeTotal;
  17.     int noDays;
  18.     char chargeService;
  19.     string namePatron;
  20.     ofstream fout("invoice.txt");
  21.     cout << fixed << setprecision(2);
  22.     fout << fixed << setprecision(2);
  23.  
  24.     //input
  25.     cout << "Name of Patron:   ";
  26.     cin >> namePatron;
  27.     cout << "Days lodged:   ";
  28.     cin >> noDays;
  29.     cout << "Room service (y/n):   ";
  30.     cin >> chargeService;
  31.     cout << "Total cost of other services:   ";
  32.     cin >> chargeMisc;
  33.     cout << endl << endl;
  34.  
  35.     //processing
  36.     chargeTotal=noDays*chargeRoomDay+chargeMisc;
  37.     if(chargeService=='y'||chargeService=='Y'){
  38.         chargeTotal+=noDays*chargeServiceDay;
  39.     }
  40.    
  41.     //output
  42.     fout << "Star Hotel Customer Invoice for Guest " << namePatron << endl;
  43.     fout << left << setw(30) << "Room Charge:" << right << setw(7) << noDays*chargeRoomDay << endl;
  44.     fout << left << setw(30) << "Number of Days:" << right << setw(7) << noDays << endl;
  45.     if(chargeService=='y'||chargeService=='Y'){
  46.         fout << left << setw(30) << "Service Charge:" << right << setw(7) << noDays*chargeServiceDay << endl;
  47.     }else{
  48.         fout << left << setw(30) << "Service Charge:" << right << setw(7) << 0.00 << endl;
  49.     }
  50.     fout << left << setw(30) << "Miscellaneous Charges:" << right << setw(7) << chargeMisc << endl << endl;
  51.     fout << left << setw(30) << "Total Room Charge:" << right << setw(7) << chargeTotal << endl;
  52.     system("type invoice.txt");
  53.    
  54.     //fin
  55.     cout << endl << "Program ended successfully" << endl;
  56.     system("pause");
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement