In: Computer Science
Software Sales A software company sells three packages, Package A, Package B, and Package C, which retail for $99, $199, and $299, respectively. Quantity discounts are given according to the following table: Quantity Discount 10 through 19 20% ,20 through 49 30% ,50 through 99 40% ,100 or more 50% . Create a C++ program that allows the user to enter the number of units sold for each software package. The application should calculate and display the order amounts and the grand total. Input validation: Make sure the number of units for each package is not negative.
Use the following test data to determine if the application is calculating properly: Units Sold Amount of Order Package A: 15 units Package A: $1,188.00
Package B: 75 units Package B: $8,955.00
Package C: 120 units Package C: $17,940.00
Grand Total: $28,083.00
#include<iostream>
using namespace std;
int getDiscount(int quantity,int price){
int total = quantity * price;
if(quantity>=10 && quantity<20)
return total * 0.2;
if(quantity>=20 && quantity<50)
return total * 0.3;
if(quantity>=50 && quantity<100)
return total * 0.4;
if(quantity>=100)
return total * 0.5;
return 0;
}
int main(){
const int PRICEA=99;
const int PRICEB=199;
const int PRICEC=299;
int quantityA,quantityB,quantityC;
cout<<"Enter quantity for package A: ";
cin>>quantityA;
cout<<"Enter quantity for package B: ";
cin>>quantityB;
cout<<"Enter quantity for package C: ";
cin>>quantityC;
int totalA= quantityA * PRICEA-getDiscount(quantityA,PRICEA);
int totalB= quantityB * PRICEB-getDiscount(quantityB,PRICEB);
int totalC= quantityC * PRICEC-getDiscount(quantityC,PRICEC);
int grandTotal = totalA + totalB + totalC;
cout<<"Package A: "<<quantityA<<" units Package A: $"<<totalA<<endl;
cout<<"Package B: "<<quantityB<<" units Package B: $"<<totalB<<endl;
cout<<"Package C: "<<quantityC<<" units Package C: $"<<totalC<<endl;
cout<<"Grand Total: $:"<<grandTotal;
}
NOTE : PLEASE COMMENT BELOW IF YOU HAVE CONCERNS.
I AM HERE TO HELP YOUIF YOU LIKE MY ANSWER PLEASE RATE AND HELP ME IT IS VERY IMP FOR ME