Question: Below is my c++ code I have that is not working and the psuedocode that I am working from. I have errors at line 10,13,16,29,34,36,and
Below is my c++ code I have that is not working and the psuedocode that I am working from. I have errors at line 10,13,16,29,34,36,and 40. How can I clear those errors and make my code work based off of the pseudocode provided:
#include
#include
using namespace std;
int main()
{
// Declare variables
int SIZE = 5;
int COFFEEPRICE = 2.00;
string products[SIZE] = ("Whipped cream", "Cinnamon", "Chocolate sauce", "Amaretto", "Irish whiskey");
double prices[SIZE] = [0.89, 0.25, 0.59, 3.69, 1.50, 1.75];
double totalPrice = 0;
int choice = 0;
while (choice !=SENTINEL)
{
cout << "Please select an item from the Product menu by selecting the item number (1 - 5) or -1 to terminate: "
cout << products[SIZE] = productPrice;
cout << "=============";
cout << "1. Whipped cream0.89";
cout << "2. Cinnamon0.25";
cout << "3. Chocolate sauce0.89";
cout << "4. Amaretto1.50";
cout << "5. Irish whiskey1.75";
cout << "Please enter a positive number: ";
cin >> choice;
}
if (choice != -1)
then
((choice >= -1) and (choice <= 5)) then
totalPrice = totalPrice + prices[choice-1];
else
{
cout << "Item number ", choice, ":" products[choice-1], "has been added";
Else
cout << "Item number ",choice, " is not valid", "Sorry we do not carry that item"<< endl;
}
totalPrice = totalPrice + COFFEEPRICE
{
cout <<"Total price of order is ",totalPrice< cout <<"Thanks for purchasing from Jumpin Jive Coffee Shop"< } return 0; } PSEUDOCODE // 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" // output "Please enter a positive number: " // input choice // if (choice <> -1) then // if ((choice >= 1) and (choice <= 5)) then // totalPrice = totalPrice + prices[choice-1] // output "Item number ", choice,": ", products[choice-1], " has been added" // else // output "Item number ",choice, " is not valid", "Sorry we do not carry that item" // endif // endif // endwhile // totalPrice = totalPrice + COFFEEPRICE // output "Total price of order is ",totalPrice // output "Thanks for purchasing from Jumpin Jive Coffee Shop" // Stop
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
