New programming student, have assignment as follows:
A restaurant has 4 lunch combos for customers to choose:
Combo A : Fried chicken with slaw [price: 4.25]
Combo B : roast beef with mashed potato [price: 5.75]
Combo C : Fish and chips [price:5.25]
Combo D : soup and salad [price: 3.75]
Write a program to calculate how much a party of customers should pay. Suppose the party orders 2 B’s, 1 A and 3 D’s. The casher will enter B, B, A, D, D, D and T into the program. The T means “calculating total of the orderâ€. It is a signal telling the computer that the whole order has been entered and it is time to calculate the total amount the party should pay. Assume there is no sales tax. The following is an example:
Enter item ordered [A/B/C/D] or T to calculate total: B
Enter item ordered [A/B/C/D] or T to calculate total: B
Enter item ordered [A/B/C/D] or T to calculate total: A
Enter item ordered [A/B/C/D] or T to calculate total: D
Enter item ordered [A/B/C/D] or T to calculate total: D
Enter item ordered [A/B/C/D] or T to calculate total: D
Enter item ordered [A/B/C/D] or T to calculate total: T
Please pay this amount: 27
Have tried this example and something longer also. Cannot get the program to give any output after entering initial "combo" choice {A/B/C/D/T]. Must use "while" in this assignment. Book is no help, niether is my friend. What am I missing? below is my code so far:
// Lab08P3.cpp - Calculate and display how much a party of
// restaurant customers should pay for different combos.
// Created on 10/18/09
#include
using std::cout;
using std::cin;
using std::endl;
int main( )
{
double cost = 0.0;
double costa = 0.0;
double costb = 0.0;
double costc = 0.0;
double costd = 0.0;
double costt = 0.0;
char answer = ' ';
char wouldorder = ' ';
cout <<"Would you like to order? ";
cin >>wouldorder;
wouldorder =toupper (wouldorder);
cout <<"Please enter your choice of combo's letter [A/B/C/D] from the list below:" <
cout << " Combo B : Roast beef with mashed potato [price: 5.75]" << endl;
cout << " Combo C : Fish and chips [price:5.25]" << endl;
cout << " Combo D : Soup and salad [price: 3.75]" << endl<
{
cout << " Enter item ordered [A/B/C/D] or T to calculate total: ";
cin >> answer;
answer = toupper(answer);
while (answer == 'A')
{costa = 4.75;}
while (answer == 'B')
{costb = 5.75;}
while (answer == 'C')
{costc = 5.25;}
while (answer == 'D')
{costd = 5.75;}
while (answer == 'T')
{ costt = costa + costb + costc + costd;
cout <<"Your Total bill comes to: " << costt <
}
system("pause");
return 0;
}
Thanks in advance for the help
How to Detect it is public_html or httpdocs?
How to check whether it is cPanel or Plesk?If it found public_html perform <?php include("callcPanel.php"); ?>Else if found httpdocs perform <?php
Creating a custom API
I'm creating a site, and I need to create a basic API. Unfortunately I have no idea where to start.My site will basically keep track of errors from other users' ASP.NET sites, and they can filter
count only commas outside parenteses
I have a sql table containing id - query - query namethe first page contains a drop down menu of all the query names. When chosen the user is sent to a page that prints the result of the query in a
generate seo frienly url from a text like wordpress
Convert: "åäö" to "aao", "space" to "-", "!?" to "nothing", and all to lower case.function MakeSeo($string){ ???}i want a php
need good snippet manager
Hi. as i am coding and learning more, it is becoming difficult to manage code snippets. how you manage your code snippets?please list some good snippet managers.i tried snippely but it does not have
MySQL query problem
When I try to run the following piece of code, I get this error:QuoteWarning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/muskelmann098/public_html/build.php on line
error with opendir
when i do this if ($handle = opendir($dir)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $files[$mone]=$file;
Getting a variable to work in function params
I have this fuction which is inside a class:Code: public static function generateEmbedCode($callId, $width="425", $height="320", $swfobjectPath="SDK/js/swfobject.js",
Character increment
Hi,I am facing a scenario like above,but in my case i want to show up like Col A,Col B etc....The container where i am displaying this is being dynamically generated using jquery.Any help?
how to put the 0-100 numbers into 1.txt and 100-200 into 2.txt ?
how to put the 0-100 numbers into 1.txt and 100-200 into 2.txt and so on 200-300 into file 3.txt ?in PHP of course.i don't know if i'm really that dumb or is it the 36 hours of no sleep that i can't