I need help with with my hw. The code bellow is what i have so far but i still need to this part which i cant figure out .
>>>>>If the quantity sold for the product is over 10, then 10% off is applied to the sales. If the quantity sold for the product is over 20 then 25% off is applied to the sales. You must create a function named Calculate which has 2 parameters to calculate the sales and return the sales. See the function maximum on page 251 for reference.<<<<<<
also i cant get the totals at the end to add up.
This is the complete problem if it helps
Problem Description
A mail-order house sells five different products whose retail prices are as follows: product 1, $2.98; product 2, $4.50; product 3, $9.98; product 4, $4.49; and product 5, $6.87. Write an application that reads a series of pairs of numbers as follows:
a) Product number
b) Quantity sold for one day
If the quantity sold for the product is over 10, then 10% off is applied to the sales. If the quantity sold for the product is over 20 then 25% off is applied to the sales. You must create a function named Calculate which has 2 parameters to calculate the sales and return the sales. See the function maximum on page 251 for reference.
Your program must use a switch structure to help determine the retail price for each product. It should calculate and display the total retail value of each product sold last week. Use a sentinel-controlled loop to determine when the program should stop looping and display the final results.
Code:#include<iostream> #include <iomanip.h> using namespace std; int main() { int ProductNumber; double QuantitySold; double sum1=0, sum2=0, sum3=0, sum4=0, sum5=0; cout<<"Enter the product number (1-5) (0 to Stop): "; cin>>ProductNumber; cout<<"Enter quantity sold: "; cin>>QuantitySold; while (ProductNumber != 0 ){ switch (ProductNumber) { case 1: sum1=(2.98*QuantitySold); cout<<"The sales for this Product 1 is $ "<<sum1<<endl; break; case 2: sum2=(4.50*QuantitySold); cout<<"The sales for this Product 2 is $ "<<sum2<<endl; break; case 3: sum3=(9.98*QuantitySold); cout<<"The sales for this Product 3 is $ "<<sum3<<endl; break; case 4: sum4=(4.49*QuantitySold); cout<<"The sales for this Product 4 is $ "<<sum4<<endl; break; case 5: sum5=(6.87*QuantitySold); cout<<"The sales for this Product 5 is $ "<<sum5<<endl; break; default: cout << "Invalid product code: " << ProductNumber << "\n Quantity: " << QuantitySold << '\n'; break; } cout<<"\nEnter the product number (1-5) (0 to Stop): "; cin>>ProductNumber; cout<<"Enter quantity sold: "; cin>>QuantitySold; } cout<<"Total Sales for the week"<<endl; cout<<"Product 1 $ "<<sum1<<endl; cout<<"Product 2 $ "<<sum2<<endl; cout<<"Product 3 $ "<<sum3<<endl; cout<<"Product 4 $ "<<sum4<<endl; cout<<"Product 5 $ "<<sum5<<endl; system ("pause"); return 0; }



LinkBack URL
About LinkBacks



