Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string>
- #include <iostream>
- #include <iomanip>
- #include <fstream>
- using namespace std;
- /*
- Name: Marshal Walker
- Assignment #1: Some half-assed "program" to do invoices.
- */
- int main()
- {
- //housekeeping
- const double chargeRoomDay=189.00, chargeServiceDay=19.00;
- double chargeMisc, chargeTotal;
- int noDays;
- char chargeService;
- string namePatron;
- ofstream fout("invoice.txt");
- cout << fixed << setprecision(2);
- fout << fixed << setprecision(2);
- //input
- cout << "Name of Patron: ";
- cin >> namePatron;
- cout << "Days lodged: ";
- cin >> noDays;
- cout << "Room service (y/n): ";
- cin >> chargeService;
- cout << "Total cost of other services: ";
- cin >> chargeMisc;
- cout << endl << endl;
- //processing
- chargeTotal=noDays*chargeRoomDay+chargeMisc;
- if(chargeService=='y'||chargeService=='Y'){
- chargeTotal+=noDays*chargeServiceDay;
- }
- //output
- fout << "Star Hotel Customer Invoice for Guest " << namePatron << endl;
- fout << left << setw(30) << "Room Charge:" << right << setw(7) << noDays*chargeRoomDay << endl;
- fout << left << setw(30) << "Number of Days:" << right << setw(7) << noDays << endl;
- if(chargeService=='y'||chargeService=='Y'){
- fout << left << setw(30) << "Service Charge:" << right << setw(7) << noDays*chargeServiceDay << endl;
- }else{
- fout << left << setw(30) << "Service Charge:" << right << setw(7) << 0.00 << endl;
- }
- fout << left << setw(30) << "Miscellaneous Charges:" << right << setw(7) << chargeMisc << endl << endl;
- fout << left << setw(30) << "Total Room Charge:" << right << setw(7) << chargeTotal << endl;
- system("type invoice.txt");
- //fin
- cout << endl << "Program ended successfully" << endl;
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement