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

Need some help please. Calculating total sales A mail order house sells five dif

ID: 3541137 • Letter: N

Question

Need some help please.


Calculating total sales


A mail order house sells five different products who retail prices are: product 1 - $2.98, product 2-$4.50, product 3-$9.98, product 4-$4.49, and product 5-$6.87. Write a program that reads a series of pairs of numbers as follows


A) product number

B) quantity sold


Your program should use a switch statement to determine the retail for each product. Your program should calcuate and display the total retail value of all products sold. Use a sentinel-controlled loop to determine when the program should stop looping and display the final result.


Thanks in advance. I need good notes too so I can learn it easier. Thanks!!

Explanation / Answer

#include<iostream>

using std::cout;

using std::cin;

using std::endl;

double calculate(int, double);

int main()

{

int product_number=0;

int quantity_sold=0;

double product_price=0;

double total_price=0;

cout << "Enter 0 or negative number to exit" << endl;

do

{

switch(product_number)

{

case 1 :

product_price = 2.98;

break;

case 2 :

product_price = 4.50;

break;

case 3 :

product_price = 9.98;

break;

case 4 :

product_price = 4.49;

break;

case 5 :

product_price = 6.87;

break;

}

total_price = total_price + (quantity_sold * product_price);

if(quantity_sold > 10)

{

cout<<"Total price is "<< calculate(total_price, quantity_sold);

}

else cout << "Total price is " << total_price;

cout << "Enter product Number : ";

cin >> product_number;

if (product_number > 0)

{

cout << "Enter quantity sold : ";

cin >> quantity_sold;

}

}while(product_number > 0);

system("pause");

return 0;

}

double calculate(int tp, double qs)

{

double t;

if(qs > 10 && qs <= 20)

{

t = (tp -(tp * 0.10));

}

else if(qs > 20)

{

t = (tp -(tp * 0.25));

}

return t;

}   

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