Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need the following pseudocode to work in a C++ compilier // Pseudocode PLD Cha

ID: 672504 • Letter: I

Question

I need the following pseudocode to work in a C++ compilier

// Pseudocode PLD Chapter 6 #7, pg. 268

//    

// Start

//     Declarations

//         num SIZE = 5

//         num COFFEEPRICE = 2.00

//         string products[SIZE]="Whipped cream", "Cinnamon", "Chocolate sauce", "Amaretto", ""Irishwhiskey"

//         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 -1to 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

Explanation / Answer

#include<string.h>
using namespace std;
const int SIZE=5;
const int COFFEEPRICE=2.00;
const string product[SIZE]={"Whipped cream","Cinnamon","Chocolate sauce","Amaretto"};
int main(){
int prices[SIZE]={0.89,0.25,0.59,1.50,1.75} ;
int totalPrice=0;
int choice=0;
int SENTINEL=-1;
while(choice!=SENTINEL)
{
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<<"1.Whipped cream"<<" "<<"0.89"<<endl;
   cout<<"2.Cinnamon"<<" "<<"0.25"<<endl;
   cout<<"3.Chocolate sauce"<<" "<<"0.89"<<endl;
   cin>>choice;
   if(choice!=-1)
   {
if(choice>=1&&choice<=5)
      {
     totalPrice=totalPrice+prices[choice-1];
     cout<<"Item number,"<<choice<<":"<<product[choice-1]<<",has been added"<<endl;
      }
      else
      {
  cout<<"Item number"<<choice<<"is not valid ,Sorry we do not carry that item"<<endl;
       }
   }
}
   totalPrice=totalPrice+COFFEEPRICE;
   cout<<"Total price of order id"<<totalPrice<<endl;
   cout<<"Thanks for purchasing from Jumpin Jive Coffee Shop"<<endl;
   return 0;
   }

Output:

Please Select an item from the product menu by selecting the item number(1-5) or -1 to terminate

Product        Price($)

1.Whipped cream 0.89

2.Cinnamon 0.25

3.Chocolate sauce 0.89

1

Item number,1:Whipped cream,has been added

Please Select an item from the product menu by selecting the item number(1-5) or -1 to terminate

Product                   Price($)

1.Whipped cream    0.89

2.Cinnamon            0.25

3.Chocolate sauce 0.89

-1 Total price of order id2 Thanks for purchasing from Jumpin Jive Coffee Shop

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote