I\'m trying to answer this question: A local department store wants a program th
ID: 3681321 • Letter: I
Question
I'm trying to answer this question: A local department store 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-45. If necessary, create a new project named Advanced18 Project, and save it in the Cpp8Chap06 folder. Enter your C++ instructions into a source file named Advanced18.cpp. Also enter appropriate comments and any additional instructions required by the compiler. Display the reward points in fixed-point notation with no decimal places. Save, run, and test the program. Total monthly Membership type purchase ($) Reward points Standard Less than 75 5% of the total monthly purchase 75–149.99 7.5% 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 Premium Less than 200 4% of the total monthly purchase 200 and over 15% of the total monthly purchase using this code: #include #include using namespace std; void displayStandard(double totalBalance); void displayPlus(double totalBalance); void displayPremium(double totalBalance); int main() { double balance = 0.0; int points = 0; cout << "Please enter your monthly balance: "; cin >> balance; displayStandard(points); displayPlus(points); displayPremium(points); system("pause"); return 0; } int rewards = 0; void displayStandard(double totalbalance) { if (totalBalance < 75) rewards = .05 * totalBalance; else if (totalBalance >= 75 & totalBalance <= 149.99) rewards = .075 * totalBalance; else (totalBalance >= 150); rewards = .10 * totalBalance; cout << "Reward points for standard: " << rewards; // end if } void displayPlus(double totalBalance) { if (totalBalance < 150) rewards = .06 * totalBalance; else rewards = .13 * totalBalance; cout << "Reward points for standard: " << rewards; }// end if void displayPremium(double totalBalance) { if (totalBalance < 200) rewards = .04 * totalBalance; else rewards = .15 * totalBalance; cout << "Reward points for standard: " << rewards; }// end if but it is not working correctly. The code only allows entrance of monthly balance and then it ends. it does not calculate rewards at all.Explanation / Answer
#include<iostream>
#include<stdlib.h>
using namespace std;
double displayStandard(double totalBalance);
double displayPlus(double totalBalance);
double displayPremium(double totalBalance);
int main() {
double balance = 0.0;
int points = 0;
cout << "Please enter your monthly balance: ";
cin >> balance;
points = displayStandard(balance);
cout << "Membership: Standard -> Reward points for standard: " << points<<endl;
points = displayPlus(balance);
cout << "Membership: Plus -> Reward points for standard: " << points<<endl;
points = displayPremium(balance);
cout << "Membership: Premium -> Reward points for standard: " << points<<endl;
//system("pause");
return 0;
}
double displayStandard(double totalBalance)
{
double rewards = 0;
if (totalBalance < 75)
rewards = .05 * totalBalance;
else if (totalBalance >= 75 && totalBalance <= 149.99)
rewards = .075 * totalBalance;
else (totalBalance >= 150);
rewards = .10 * totalBalance;
return rewards;
}
double displayPlus(double totalBalance) {
double rewards = 0;
if (totalBalance < 150)
rewards = .06 * totalBalance;
else
rewards = .13 * totalBalance;
return rewards;
}
double displayPremium(double totalBalance) {
double rewards = 0;
if (totalBalance < 200)
rewards = .04 * totalBalance;
else rewards = .15 * totalBalance;
return rewards;
}
/*
Output:
Please enter your monthly balance: 75
Membership: Standard -> Reward points for standard: 7
Membership: Plus -> Reward points for standard: 4
Membership: Premium -> Reward points for standard: 3
*/