Shopper Stoppers wants an application that displays the number of reward points
ID: 3675139 • Letter: S
Question
Shopper Stoppers wants an application that displays the number of reward points a customer
earns each month. The reward points are based on the customer’s membership type and total
monthly purchase amount, as shown in Figure 5-50. Use the following names for the solution
and project, respectively: Shopper Solution and Shopper Project. Save the solution in the
VbReloaded2012Chap05 folder. Change the form file’s name to Main Form.vb. You can either
create your own user interface or create the one shown in Figure 5-51. Display the reward points
without any decimal places. (1-7, 10)
Membership Type Total monthly purchase ($) Reward points
Basic Less than 100 - 5% of the total monthly purchase
100 and over - 7% of the total monthly purchase
Standard - Less than 150 - 6% of the total monthly purchase
150 – 299.99 - 8% of the total monthly purchase
300 and over - 10% of the total monthly purchase
Premium - Less than 200 - 7% of the total monthly purchase
200 and over - 15% of the total monthly purchase
Explanation / Answer
#include <stdlib.h>
#include <iostream>
#include <stdio.h>
#include <cstdlib>
using namespace std;
class Customer
{
private:
int customer_id;
int membership_type;
float monthly_purchase;
float reward_points;
public:
Customer()
{
membership_type = 0; monthly_purchase = 0; reward_points = 0;
}
int GetMonthlyPurchase() {return monthly_purchase;
}
void EnterData(int numberOfCustomer)
{
customer_id = numberOfCustomer;
do
{
system("cls");
cout<<"Enter the membership type for "<<numberOfCustomer<<" customer : "<<endl;
cout<<"1. Standard"<<endl;
cout<<"2. Plus"<<endl;
cin>>membership_type;
}
while (membership_type < 1 || membership_type > 2);
do
{
system("cls");
cout<<"Enter the monthly purchase for "<<numberOfCustomer<<" customer : ";
cin>>monthly_purchase;
}
while (monthly_purchase < 0);
}
void CalculateRewardPoints(float totalMonthlyPurchase)
{
switch (membership_type)
{
case 1:
{
if (monthly_purchase < 75 ) reward_points = float(0.05 * totalMonthlyPurchase);
if (monthly_purchase >= 75 && monthly_purchase < 150) reward_points = float( 0.075 * totalMonthlyPurchase);
if (monthly_purchase >= 150 ) reward_points = float(0.1 * totalMonthlyPurchase);
}
break;
case 2:
{
if (monthly_purchase < 150) reward_points = 0.06 * totalMonthlyPurchase;
if (monthly_purchase >= 150) reward_points = 0.13 * totalMonthlyPurchase;
}
break;
}
}
void DisplayData()
{
cout<<"--------------------------------------------------------"<<endl;
cout<<"Customer number : "<<customer_id<<endl;
if (membership_type == 1) cout<<"Membership type : Standart"<<endl;
else
cout<<"Membership type : Plus"<<endl;
cout<<"Monthly purchase : "<<monthly_purchase<<endl;
cout<<"Rewards points : "<<reward_points<<endl;
cout<<"--------------------------------------------------------"<<endl;
}
};
int main()
{
int n;
cout<<"Enter the number of customer's : ";
cin>>n;
int total_monthly_purchase = 0;
Customer *mas = new Customer[n];
for (int i = 0; i < n; i++)
{
mas[i].EnterData(i+1);
total_monthly_purchase += mas[i].GetMonthlyPurchase();
}
system("cls");
for (int i = 0; i < n; i++)
{
mas[i].CalculateRewardPoints(total_monthly_purchase);
mas[i].DisplayData();
}
system("pause");
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.