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

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

View Full Document Right Arrow Icon
//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; }
Background image of page 1

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

View Full DocumentRight Arrow Icon
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"
Background image of page 2
Background image of page 3
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( &quot;bill.txt&quot; ); fout &lt;&lt; endl &lt;&lt; setw(39) &lt;&lt; &quot;Thank you for dining with us!\n&quot; &lt;&lt; endl; fout &lt;&lt; setw(20) &lt;&lt; &quot;Chicken Dinner&quot; &lt;&lt; setw( 8 ) &lt;&lt; &quot;$&quot; &lt;&lt; chickencost &lt;&lt; endl; fout &lt;&lt; setw(20) &lt;&lt; &quot;Beef Dinner&quot; &lt;&lt; setw( 8 ) &lt;&lt; &quot;$&quot; &lt;&lt; beefcost &lt;&lt; endl; fout &lt;&lt; setw(20) &lt;&lt; &quot;Gratuity&quot; &lt;&lt; setw( 8 ) &lt;&lt; &quot;$&quot; &lt;&lt; tip &lt;&lt; endl; fout &lt;&lt; setw(20) &lt;&lt; &quot;Room Rental&quot; &lt;&lt; setw( 8 ) &lt;&lt; &quot;$&quot; &lt;&lt; room &lt;&lt; endl; fout &lt;&lt; setw(20) &lt;&lt; &quot;Room Tax&quot; &lt;&lt; setw( 8 ) &lt;&lt; &quot;$&quot; &lt;&lt; roomcost &lt;&lt; endl; fout &lt;&lt; setw(34) &lt;&lt; &quot;-------&quot; &lt;&lt; endl; fout &lt;&lt; setw(20) &lt;&lt; &quot;Total&quot; &lt;&lt; setw( 8 ) &lt;&lt; &quot;$&quot; &lt;&lt; total &lt;&lt; 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

This homework help was uploaded on 04/18/2008 for the course COS 220 taught by Professor Roberts during the Spring '08 term at University of Maine Orono .

Page1 / 3

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

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online