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

A software company sells a package that retails for $96. Quantity discounts are

ID: 3683171 • Letter: A

Question

A software company sells a package that retails for $96. Quantity discounts are given according to the following table: Quantity Discount 16-29 46-89 No discount 15% 20% 25% Note that if a customer purchases 16-29 units they get a 10% discount on all of the units they purchase. The rule is the same for the rest of the discount levels they get that discount for their entire purchase. If the number of units sold is 200 or more output a message saying the customer is a Think about the types of things that could change in the future as the business changes. It is likely that the price of the software could change Also, the company may want to change the discount levels and discount percentages. The company could add new discount levels or reduce the number of discount levels. Finally, the number of units that have to be sold to be a preferred customer could change as well You need to think about how you can write your code so that these changes can be made in a way that minimizes the amount of code that has to change. The retail price of the software must be kept in a const variable and not hard coded in your application code. Note that the const variables are NOT global You will have to decide what functions need the const variables. The same is true for all of the discounts and quantity levels, and for the preferred customer level. These must also be const variables. For example, the list price and preferred customer values can be defined as follows (you can use different names if you want to): const double RETAIL PRICE 96.0 const int PREFERRED_CUSTOMER LEVEL -200: You will be using a set of functions do to the following tasks. See details see the section "Function General tasks for the application . You will be writing a program that asks the user for the number of units sold (read using cin) and computes the total sales for the purchase. The application needs to output the discount the customer qualified for the number of units sold and the amount of the sale. Your application will output a message if the customer is a preferred customer Keep the calculated total sales in a variable. · . Your application must validate the input and make sure the number of units is greater than o.If the input quantity is not valid you need to output a message and exit the program Function requirements: Here is a summary of what needs to be done in the main function: Call the getQuantity function. This will return back the input from the application user. A return value of O indicates that no processing should be performed. A value greater than 0, the number of items being purchased, will be processed as follows The following steps, in your main function, all of these tasks assume that the value returned back from getQuantity is 0

Explanation / Answer

#include <iostream>
using namespace std;

int getQuantity(){
   cout << "Enter the quantity: ";
   int qty;
   cin >> qty;
   if(qty < 1){
       cout << "Invalid input ";
       qty = 0;
   }
   return qty;
}

double getDiscount(int quantity){
   if(quantity >= 1 && quantity <= 15) return 0;
   if(quantity >= 16 && quantity <= 29) return .10;
   if(quantity >= 30 && quantity <= 45) return .15;
   if(quantity >= 46 && quantity <= 89) return .20;
   if(quantity >= 90) return .25;
}

double calculateSale(int quantity, double discount){
   const double RETAIL_PRICE = 96.0;
   return quantity * (RETAIL_PRICE - RETAIL_PRICE * discount);
}

void displaySale(int quantity, double discount, double revenue){
   cout << "Quantity: " << quantity << " ";
   cout << "Discount: " << discount << " ";
   cout << "Revenue: " << revenue << " ";
}

bool isPreferred(int quantity){
   return quantity >= 200;
}

void displayPreferred(){
   cout << "This is a preferred customer ";
}

int main(){
   int quantity = getQuantity();
   if(quantity == 0) return 0;
   double discount = getDiscount(quantity);
   double sale = calculateSale(quantity, discount);
   displaySale(quantity, discount, sale);
   if(isPreferred(quantity)){
       displayPreferred();
   }
}

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