Question

In: Computer Science

A customer in a grocery store is purchasing three items. Write the pseudo code that will:...

A customer in a grocery store is purchasing three items. Write the pseudo code that will:

• Ask the user to enter the name of the first item purchased. Then ask the user to enter the cost of the first item purchased. Make your program user friendly. If the user says the first item purchased is milk, then ask: “What is the cost of milk.” [This should work no matter what item is entered by the user. I might buy candy rather than milk.]

• Ask the user to enter the name and cost of the second item purchased.

• Ask the user to enter the name and cost of the third item purchased.

• Calculate the amount of sales tax due on the total purchase price. The sales tax rate is 5%.

• Tell the user • The name and price of each item entered

• The total cost of the items purchased • The amount of sales tax due on the total purchase.

• The total amount due from the user [total cost plus sales tax] • Hint: Your first line of code should be: constant real SALES_TAX_RATE = .05;

Structure your code as follows: 1. Declare variables 2. Get user input 3. Do calculations. 4. Output what is required

Idk if its c or c++ but this is an example I have, need it to be written like that

// declare variables
Real totalSales;
Real profits;

// get user input
print "Enter amount of total sales";
totalSales = User Input;

// do calculations
profit = totalSales * .10;

// output
print "Your profit is", profit;

Solutions

Expert Solution

#include<iostream>
using namespace std;
int main()
{
   const double SALES_TAX_RATE =.05;
   string item1,item2,item3;
   double cost1,cost2,cost3;
   //reading input
   cout<<"Enter name of item:";
   cin>>item1;
   cout<<"Enter cost of "<<item1<<":";
   cin>>cost1;
   cout<<"Enter name of item:";
   cin>>item2;
   cout<<"Enter cost of "<<item2<<":";
   cin>>cost2;
  
   cout<<"Enter name of item:";
   cin>>item3;
   cout<<"Enter cost of "<<item3<<":";
   cin>>cost3;
  
   //computing displaying output
   cout<<item1<<" cost :"<<cost1<<endl;
   cout<<item2<<" cost :"<<cost2<<endl;
   cout<<item3<<" cost :"<<cost3<<endl;
  
   double TotalSales = cost1+cost2+cost3;
   cout<<"Total cost of items purchased :"<<TotalSales<<endl;
   double SalesTax = TotalSales*SALES_TAX_RATE;
   cout<<"The amount of sales tax due on the total purchase :"<<SalesTax<<endl;
   cout<<"The total amount due from the user :"<<TotalSales+SalesTax<<endl;
  
   return 0;
}

output:

Enter name of item:milk
Enter cost of milk:100
Enter name of item:cofee
Enter cost of cofee:120
Enter name of item:pepsi
Enter cost of pepsi:20
milk cost :100
cofee cost :120
pepsi cost :20
Total cost of items purchased :240
The amount of sales tax due on the total purchase :12
The total amount due from the user :252


Process exited normally.
Press any key to continue . . .



Related Solutions

A customer comes into a grocery store and buys 8 items. Write a PYTHON program that...
A customer comes into a grocery store and buys 8 items. Write a PYTHON program that asks for the name of the item and the price of each item, and then displays these on the screen. Refer to the print() and input() statements covered in the module. Do NOT use loops as it will be covered in later modules. Apples 2.10 Hamburger 3.25 Milk 3.49 Sugar 1.99 Bread 1.76 Deli Turkey 7.99 Pickles 3.42 Butter 2.79
A customer in a store is purchasing two items. Design a program using module pseudocode that...
A customer in a store is purchasing two items. Design a program using module pseudocode that asks for the price of each item in dollars, and then displays three things in their output receipt - the subtotal of the sale in dollars, the amount of sales tax in dollars and the final amount paid by the customer in dollars. Assume the sales tax is 4 percent.
Python: Write a program to simulate the purchases in a grocery store. A customer may buy...
Python: Write a program to simulate the purchases in a grocery store. A customer may buy any number of items. So, you should use a while loop. Your program should read an item first and then read the price until you enter a terminal value (‘done’) to end the loop. You should add all the prices inside the loop. Add then a sales tax of 8.75% to the total price. Print a receipt to indicate all the details of the...
Calculate your Customer Lifetime Value (CLTV) as a grocery customer. How should a grocery store segment...
Calculate your Customer Lifetime Value (CLTV) as a grocery customer. How should a grocery store segment its market? Why? Create personas for each market segment the store should have.
Here are some prices for randomly selected grocery items from the grocery store: Items Prices: Cheese...
Here are some prices for randomly selected grocery items from the grocery store: Items Prices: Cheese $3.29 Butter $4.99 Eggs $3.49 Yogurt $3.49 Juice $3.89 Tea $3.69 Chips $3.99 Soda $1.99 Pastry $2.99 Cerrial $4.99 Oats $3.29 Almond Milk $2.79 Almonds $4.39 Popcorn $3.29 Crackers $3.59 Ice Cream $6.99 Cookies $2.99 Jam $3.69 Peanut Butter $3.29 Coffee $3.19 Green Tea $4.99 BBQ Sauce $2.99 Oil $6.69 Mayonnaise $4.59 Mustard $2.99 1. Compute the sample mean x and the sample standard...
Here are some prices for randomly selected grocery items from the grocery store: Items Prices: Cheese...
Here are some prices for randomly selected grocery items from the grocery store: Items Prices: Cheese $3.29 Butter $4.99 Eggs $3.49 Yogurt $3.49 Juice $3.89 Tea $3.69 Chips $3.99 Soda $1.99 Pastry $2.99 Cerrial $4.99 Oats $3.29 Almond Milk $2.79 Almonds $4.39 Popcorn $3.29 Crackers $3.59 Ice Cream $6.99 Cookies $2.99 Jam $3.69 Peanut Butter $3.29 Coffee $3.19 Green Tea $4.99 BBQ Sauce $2.99 Oil $6.69 Mayonnaise $4.59 Mustard $2.99 1. Compute the sample mean x and the sample standard...
Here are some prices for randomly selected grocery items from the grocery store: Items Prices: Cheese...
Here are some prices for randomly selected grocery items from the grocery store: Items Prices: Cheese $3.29 Butter $4.99 Eggs $3.49 Yogurt $3.49 Juice $3.89 Tea $3.69 Chips $3.99 Soda $1.99 Pastry $2.99 Cerrial $4.99 Oats $3.29 Almond Milk $2.79 Almonds $4.39 Popcorn $3.29 Crackers $3.59 Ice Cream $6.99 Cookies $2.99 Jam $3.69 Peanut Butter $3.29 Coffee $3.19 Green Tea $4.99 BBQ Sauce $2.99 Oil $6.69 Mayonnaise $4.59 Mustard $2.99 1. Compute the sample mean x and the sample standard...
Here are some prices for randomly selected grocery items from the grocery store: Items Prices: Cheese...
Here are some prices for randomly selected grocery items from the grocery store: Items Prices: Cheese $3.29 Butter $4.99 Eggs $3.49 Yogurt $3.49 Juice $3.89 Tea $3.69 Chips $3.99 Soda $1.99 Pastry $2.99 Cerrial $4.99 Oats $3.29 Almond Milk $2.79 Almonds $4.39 Popcorn $3.29 Crackers $3.59 Ice Cream $6.99 Cookies $2.99 Jam $3.69 Peanut Butter $3.29 Coffee $3.19 Green Tea $4.99 BBQ Sauce $2.99 Oil $6.69 Mayonnaise $4.59 Mustard $2.99 1. Compute the sample mean x and the sample standard...
produce the pseudo code for the Barber routine Clipaway() and the Customer routine Cutmyhair() such that...
produce the pseudo code for the Barber routine Clipaway() and the Customer routine Cutmyhair() such that each customer is given a customized haircut and each customer pays for the Barber’s service. The Sleeping Barber Problem This works for a shop that holds a total of N customers with one barber. If a customer cannot enter the shop, the customer will be forced into the street. Start the Barber before the customers. Shared variables: const int num_chairs = N; // number...
A customer has purchased 15 items in a department store.
A customer has purchased 15 items in a department store. Write a code segment to read the unit price and the quantity of each these 15 items and to compute and print its price (which is the unit price times the quantity). Also compute and print average price of the 15 items.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT