Type
Price/Kg (RM) Discount
Grade AA Grade AAA Total Purchase >
RM200
Ajwa 45.00 75.00 5%
Mariami 50.99 90.99 8%
Safawi 47.50 85.90 6%
Given a table of prices according to type of dates and discount percentages. Write a complete
C++ program based on the following requirements.
a. main() should request required inputs
b. Include a function to display menu for type of dates dan grades.
c. Include a function that receive type, grade, quantity and price. The function will
calculate price and update parameter price. Make price as parameter pass by
reference.
d. Include a function that receive price and discount percentage and return discounted
price.
e. main() should repeatedly request input, use all functions defined and display final
price until user request to stop. Use flag variable as terminating condition.
* Do not use string as data type, use char[x] instead.
using namespace std;
/*
Price/Kg (RM) Discount
Grade AA Grade AAA Total Purchase >
RM200
Ajwa 45.00 75.00 5%
Mariami 50.99 90.99 8%
Safawi 47.50 85.90 6%
Given a table of prices according to type of dates and discount percentages.Â
Write a complete c++ program based on the following requirements.
a. main() should request required inputs
b. Include a function to display menu for type of dates dan grades.
c. Include a function that receive type, grade, quantity and price. The function will
calculate price and update parameter price. Make price as parameter pass by reference.
d. Include a function that receive price and discount percentage and return discounted price.
e. main() should repeatedly request input, use all functions defined and display finalprice until user request to stop. Use flag variable as terminating condition.
* Do not use string as data type, use char[x] instead.
*/
#define NO_OF_ITEMS 100
int main()
{
char Type[NO_OF_ITEMS][20];
float Price[NO_OF_ITEMS],Discount[NO_OF_ITEMS],Qty[NO_OF_ITEMS],Amount,Total=0;
int Flag=1,n=0;
while(Flag)
{
cout<<"\n\tEnter Type  : "; cin>>Type[n];
cout<<"\n\tEnter Price  : "; cin>>Price[n];
cout<<"\n\tEnter Discount: "; cin>>Discount[n];
cout<<"\n\tEnter Qty.  : "; cin>>Qty[n];
cout<<"\nPress-0 to QUIT"; Â cin>>Flag;
if(Flag) n++;
}
for(int r=0;r<n;r++)
{
Amount = Price[r]*Discount[rr]/100;
cout<<"\n\tType: "<<Type[r]<<"\tPrice: "<<Price[r]<<"\tDiscount: "<<Discount[r]<<"%\tAmount: "<<Amount;
Total = Total + Amount;
}
cout<<"\n\n\tTotal Amount = "<<Total;
return(0);
}
Comments
Leave a comment