any idea why the compiler says that my const ints are not declared in my code? Or any suggestions on routes to take next to completing the assignment?
The Directions for the assignment are below...
Write a menu‐driven C++ program for food purchases at the baseball stadium’s restaurant. The main
program will loop allowing the user to select food items from the menu adding each item to the bill,
terminating when the user selects the “End order” item. The program will then calculate and display the
total bill with tax (.065) and tip (.20); tip is calculated on the pretax bill. The program also needs to
collect payment and calculate change due.
Requirements:
1. Functions :
a. Define a void function without parameters to display the food menu and prices
b. Define a void function with 4 parameters (bill, totBill, tax, tip) to display the bill
c. Define a void function with 2 parameters (totBill, amtTendered) to calculate and display
the change due
2. Global variables may not be used. All variables used in functions must be passed by parameters
or declared locally.
3. Program must be menu‐driven
4. Input validation for menu item choice and amount tendered.
5. Verify that the customer tendered an amount that is equal to or greater than the total bill.
6. Output must be labelled and easy to read as shown in the sample output below. Only display 2
decimal points when displaying Total Amount Due and Change Due.
Sample Output:
Baseball Game Snack Menu
1 – Hamburger $6.00
2 – Hotdog $4.50
3 – Peanuts $3.75
4 – Popcorn $5.50
5 – Soda $2.80
6 – Chips $1.00
7 – Water $2.00
8 – End order
Enter menu item: 2
Enter menu item: 5
Enter menu item: 6
Enter menu item: 9
Incorrect menu selection, please reenter: 8
Bill = $8.30
Tax = .54
Tip = $1.66
Total amount due: $10.50
Amount tendered: $10.00
Amount paid is not enough to cover bill, please enter new amount: $15.00
Change due: $4.50
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
|
//07/08/17
//restaraunt menu
//program calculates food cost
//_______________________________________________________________________________________________Header________________________________
#include <iostream>
#include <iomanip>
using namespace std;
//prototypes
void noahsMenu();
int main()
//______________________________________________________________________________________________/Header____________________________________________
{
//*************************menu choice # variables*************************
const int hamburgerPick = 1, hotdogPick = 2, peanutsPick = 3,
popcornPick = 4, sodaPick = 5, chipsPick = 6,
waterPick = 7, EndOrderPick = 8;
int pick;
//**********************// menu price variables******************************
const double hamburger = 6.00, hotdog = 4.50, peanuts = 3.75,
popcorn = 5.50, soda = 2.80, chips = 1.00 ,
water = 1.00;
//**********************************************************************
// function menu call
noahsMenu();
// choose what you want
cin >> pick;
menuSelection();
}
//******************************************************************************************************************************************
//* *** * * function shows the menu for Noahs restaraunt. *** *
//******************************************************************************************************************************************
void noahsMenu()
{
cout << "Noahs Restaraunt Menu ";
COUT << "________________________";
cout << 1 << "Hamburger " << "--$6.00 " << endl ;
cout << 2 << "Hotdog " << "--$4.50 " << endl ;
cout << 3 << "Peanuts" << "-- 3.75 " << endl ;
cout << 4 << "Popcorn " << "--5.50 " << endl ;
cout << 5 << "Soda " << "-- 2.80 " << endl ;
cout << 6 << "Chips " << "-- 1.00 " << endl ;
cout << 7 << "Water" << "-- 1.00 " << endl ;
cout << 8 << "End Order " ;
}
//*********************************************************************************************************************************************
//* *
//*********************************************************************************************************************************************
//***********************************************************************************************************************************************
//***********************************************************************************************************************************************
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Menu selection function !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! * *
//
int menuSelection()
{
if (pick > 0 && pick < 8)
cout << pick;
else if (pick == 8)
cout << " Sorry, please choose a valid option.";
else if (pick = 1)
{
price += 6.0
}
else if (pick = 2)
{
price += 4.5
}
else if (pick += 3)
{
price += 3.75
}
else if (pick += 4)
{
price += 5.5
}
else if (pick += 5)
{
price + = 2.8
}
else if (pick += 6)
{
price += 1.0
}
else if (pick = 7)
{
price += 1.0
}
else if (pick == 8)
cout << " Sorry, please choose a valid option.";
}
// *
//***********************************************************************************************************************************************
//***********************************************************************************************************************************************
}
|