{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# C++HW2 - return 1 float roomcost/Cost of room tax roomcost...

This preview shows pages 1–3. Sign up to view the full content.

//Homework #2 //This program creates a bill for a meal including the food, room rental, tax, and tip. #include <iostream> #include <iomanip> #include <fstream> using namespace std; int main() { ofstream fout; fout << fixed << setprecision ( 2 ); int chicken; //# of chicken meals int beef; //# of beef meals cout << "How many Chicken meals? " ; cin >> chicken; double chickencost; //Cost of chicken meals if (chicken >= 0) { chickencost = chicken * 10.95; } else { cout << "Incorrect Response\nGood Bye\n" ; return 1; } cout << "How many Beef meals? " ; cin >> beef; double beefcost; //Cost of beef meals if (beef >= 0) { beefcost = beef * 15.95; } else { cout << "Incorrect Response\nGood Bye\n" ; return 1; }

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
int guests; //# of guests guests = beef + chicken; double foodcost; //Total food cost before gratuity foodcost = chickencost + beefcost; float tip; //Gratuity cost tip = foodcost * .15; double room; //Room fee if (guests <= 30) { room = 50; } else { if { room = 75; } else { if (guests > 100 && guests <= 200) { room = 100; } else { cout << "Party too large to accomadate\nSorry\n"
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ; return 1; } } } float roomcost; //Cost of room tax roomcost = room * .065; double total; //Total cost of everything total = foodcost + tip + room + roomcost; fout.open( "bill.txt" ); fout << endl << setw(39) << "Thank you for dining with us!\n" << endl; fout << setw(20) << "Chicken Dinner" << setw( 8 ) << "\$" << chickencost << endl; fout << setw(20) << "Beef Dinner" << setw( 8 ) << "\$" << beefcost << endl; fout << setw(20) << "Gratuity" << setw( 8 ) << "\$" << tip << endl; fout << setw(20) << "Room Rental" << setw( 8 ) << "\$" << room << endl; fout << setw(20) << "Room Tax" << setw( 8 ) << "\$" << roomcost << endl; fout << setw(34) << "-------" << endl; fout << setw(20) << "Total" << setw( 8 ) << "\$" << total << endl; fout.close(); return 0; } Thank you for dining with us! Chicken Dinner \$547.50 Beef Dinner \$398.75 Gratuity \$141.94 Room Rental \$75.00 Room Tax \$4.88-------Total \$1168.06...
View Full Document

{[ snackBarMessage ]}

### Page1 / 3

C++HW2 - return 1 float roomcost/Cost of room tax roomcost...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online