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
|
// Start
// Declarations
// num SIZE = 5
// num COFFEEPRICE = 2.00
// string products[SIZE]="Whipped cream", "Cinnamon", "Chocolate sauce", "Amaretto", ""Irish whiskey"
// num prices[SIZE]=0.89, 0.25, 0.59, 1.50, 1.75
// num totalPrice = 0
// num choice = 0
// num SENTINEL = -1
//
// while (choice <> SENTINEL))
// output "Please select an item from the Product menu by selecting the item number (1 - 5) or -1 to terminate: "
// output "Product Price ($)"
// output "======= ========="
// output "1. Whipped cream 0.89"
// output "2. Cinnamon 0.25"
// output "3. Chocolate sauce 0.89"
// output "4. Amaretto 1.50"
// output "5. Irish whiskey 1.75"
// total = total + numbers[counter]
// output "Please enter a positive number: "
// input choice
// if (choice <> -1) then
// if ((choice >= 1) and (choice <= 5)) then
// totalPrice = totalPrice + prices[choice]
// output "Item number ", choice,": ", products[choice], " has been added"
// else
// output "Item number ",choice, " is not valid", "Sorry we do not carry that item"
// endif
// endif
// endwhile
// output "Total price of order is ",totalPrice
// output "Thanks for purchasing from Jumpin Jive Coffee Shop"
// Stop
#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;
int main()
{
const int SIZE = 5;
double COFFEEPRICE = 2.00;
string products[SIZE] = {"Whipped cream", "Cinnamon", "Chocolate sauce", "Amaretto", "Irish whiskey"};
double prices[SIZE] = {0.89, 0.25, 0.59, 1.50, 1.75};
double totalPrice = 0;
int choice = 0;
int SENTINEL = -1;
cout << "Please select an item from the Product menu by selecting the item number (1 - 5) or -1 to terminate: " << endl;
cout << "Product Price ($)" << endl;
cout << "======= =========" << endl;
cout << "1. Whipped cream 0.89" << endl;
cout << "2. Cinnamon 0.25" << endl;
cout << "3. Chocolate sauce 0.89" << endl;
cout << "4. Amaretto 1.50" << endl;
cout << "5. Irish Whiskey 1.75" << endl;
cout << "Please enter a positive number: ";
cin >> choice;
if(choice != -1)
{
if(choice >= 1 && choice <= 5)
{
totalPrice = COFFEEPRICE + prices[choice];
cout << "Item number " << choice << ": " << products[choice] << " has been added" << endl;
}
else
{
cout << "Item number " << choice << " is not valid" << endl;
cout << "Sorry we do not carry that item" << endl;
}
}
cout << "Total price of order is: $" << totalPrice << endl;
cout << "Thanks for purchasing from Jumpin Jive Coffee Shop" << endl;
system("PAUSE");
return 0;
}
|