66 951
Assignments Done
99,1%
Successfully Done
In October 2018

Answer to Question #48739 in C++ for ama

Question #48739
Shopper Haven wants a program 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 6-53.

membership type total monthly purchase ($) reward points
Standard less than 75 5% of the total monthly purchase
75-149.99 75% of the total monthly purchase
150 and over 10% of the total monthly purchase

Plus Less than 150 6% of the total monthly purchase
150 and over 13% of the total monthly purchase

Expert's 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;
}


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions