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

Someone helped me and code this progeam but still my professor says There is not

ID: 3863030 • Letter: S

Question

Someone helped me and code this progeam but still my professor says There is nothing in your code indicating that the reward points will display with fixed point notation with no decimal places .Please help me to fix it

Here is code:

#include <iostream>
#include <iomanip>
using namespace std;

//Function prototypes
void standard(double purchaseAmt);
void plusMemberShip(double purchaseAmt);
void premium(double purchaseAmt);

//Program begins with a main function
int main()
{
//Declare variables
char membershipType;
double purchaseAmt = 0.0;
//Prompt and read the membership type
cout << "Membership types: " << endl;
cout << " Standard = S " << endl;
cout << " Plus = P " << endl;
cout << " Premium = R " << endl;
cout << "Enter membership type(S/P/R): ";
cin >> membershipType;

//Prompt and read the total monthly purchase amount
cout << "Enter total monthly purchase amount: ";
cin >> purchaseAmt;
// fixed point notation with no decimal places
cout << std::fixed;
cout << std::setprecision(0); // zero means no decimal places

if (membershipType == 'S' || membershipType == 's')
{
//function calls
standard(purchaseAmt);
}
else if (membershipType == 'P' || membershipType == 'p')
{
plusMemberShip(purchaseAmt);
}
else if (membershipType == 'R' || membershipType == 'r')
{
premium(purchaseAmt);
}
else
cout << " Invalid member ship type" << endl;
cout << endl;
//Pause the system for a while
system("pause");
return 0;
}
double rewardPoints = 0;
//Method definition of standard
void standard(double purchaseAmt)
{
if (purchaseAmt < 75)
rewardPoints = 0.05 * purchaseAmt;
else if (purchaseAmt >= 75 && purchaseAmt <= 149.99)
rewardPoints = 0.075 * purchaseAmt;
else (purchaseAmt >= 150);
rewardPoints = 0.10 * purchaseAmt;
cout << " Reward points in Standard membership: " << rewardPoints << endl;
}
//Method definition of plusMemberShip
void plusMemberShip(double purchaseAmt)
{
if (purchaseAmt < 150)
rewardPoints = 0.06 * purchaseAmt;
else
rewardPoints = 0.13 * purchaseAmt;
cout << " Reward points in plus membership: " << rewardPoints << endl;

}
//Method definition of premium
void premium(double purchaseAmt)
{
if (purchaseAmt < 200)
rewardPoints = 0.04 * purchaseAmt;
else
rewardPoints = 0.15 * purchaseAmt;
cout << " Reward points in premium membership: " << rewardPoints << endl;
}

Explanation / Answer

Hi

I dont see any issue with the code. It is working as excepted and also we are written a code to handle with fixed point notation with no decimal places.

Highlighted the code indicates that fixed point notation with no decimal places.

#include <iostream>
#include <iomanip>
using namespace std;

//Function prototypes
void standard(double purchaseAmt);
void plusMemberShip(double purchaseAmt);
void premium(double purchaseAmt);

//Program begins with a main function
int main()
{
//Declare variables
char membershipType;
double purchaseAmt = 0.0;
//Prompt and read the membership type
cout << "Membership types: " << endl;
cout << " Standard = S " << endl;
cout << " Plus = P " << endl;
cout << " Premium = R " << endl;
cout << "Enter membership type(S/P/R): ";
cin >> membershipType;

//Prompt and read the total monthly purchase amount
cout << "Enter total monthly purchase amount: ";
cin >> purchaseAmt;
// fixed point notation with no decimal places
cout << std::fixed;
cout << std::setprecision(0); // zero means no decimal places

if (membershipType == 'S' || membershipType == 's')
{
//function calls
standard(purchaseAmt);
}
else if (membershipType == 'P' || membershipType == 'p')
{
plusMemberShip(purchaseAmt);
}
else if (membershipType == 'R' || membershipType == 'r')
{
premium(purchaseAmt);
}
else
cout << " Invalid member ship type" << endl;
cout << endl;
//Pause the system for a while
system("pause");
return 0;
}
double rewardPoints = 0;
//Method definition of standard
void standard(double purchaseAmt)
{
if (purchaseAmt < 75)
rewardPoints = 0.05 * purchaseAmt;
else if (purchaseAmt >= 75 && purchaseAmt <= 149.99)
rewardPoints = 0.075 * purchaseAmt;
else (purchaseAmt >= 150);
rewardPoints = 0.10 * purchaseAmt;
cout << " Reward points in Standard membership: " << rewardPoints << endl;
}
//Method definition of plusMemberShip
void plusMemberShip(double purchaseAmt)
{
if (purchaseAmt < 150)
rewardPoints = 0.06 * purchaseAmt;
else
rewardPoints = 0.13 * purchaseAmt;
cout << " Reward points in plus membership: " << rewardPoints << endl;

}
//Method definition of premium
void premium(double purchaseAmt)
{
if (purchaseAmt < 200)
rewardPoints = 0.04 * purchaseAmt;
else
rewardPoints = 0.15 * purchaseAmt;
cout << " Reward points in premium membership: " << rewardPoints << endl;
}

Output:

sh-4.2$ g++ -std=c++11 -o main *.cpp                                                                                                                                                                                                                                   

sh-4.2$ main                                                                                                                                                                                                                                                           

Membership types:                                                                                                                                                                                                                                                      

Standard = S                                                                                                                                                                                                                                                          

Plus = P                                                                                                                                                                                                                                                              

Premium = R                                                                                                                                                                                                                                                           

Enter membership type(S/P/R): S                                                                                                                                                                                                                                        

Enter total monthly purchase amount: 33                                                                                                                                                                                                                                

                                                                                                                                                                                                                                                                       

Reward points in Standard membership: 3

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