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

Please, do you mind modify this program and add the following features: Add fami

ID: 3769444 • Letter: P

Question

Please, do you mind modify this program and add the following features:

Add family membership for $60, Add the code to write new membership accounts to the file "members.txt", Add choice to the menu to view member accounts, "members.txt", Counts of each type of membership processed and display to the console at the end, quit and Tip - use an array of counters.

// This menu-driven Health Club membership program carries out the

// appropriate actions based on the menu choice entered. A do-while loop

// allows the program to repeat until the user selects menu choice 4.

#include <iostream>

#include <iomanip>

using namespace std;

// Constants for membership rates

const double ADULT_RATE = 40.0;

const double CHILD_RATE = 20.0;

const double SENIOR_RATE = 30.0;

void displayMenu();  

void verifyChoice(int &);

void processChoice(int &);

int main()

{

        int choice;           // Menu choice

   do

   {

        displayMenu();

        cin >> choice;

        verifyChoice(choice);

        processChoice(choice);

              

   } while (choice != 4); // Loop again if the user did not

   system("pause");       // select choice 4 to quit

   return 0;

}

void displayMenu(){

// Display the menu and get the user's choice

      cout << "    Health Club Membership Menu ";

       cout << "1. Standard Adult Membership ";

       cout << "2. Child Membership ";

           cout << "3. Senior Citizen Membership ";

           cout << "4. Quit the Program ";

           cout << "Enter your choice: ";

}

void verifyChoice(int &choice)

{

    // Validate the menu selection

        while ((choice < 1) || (choice > 4))

               {

                  cout << "Please enter 1, 2, 3, or 4: ";

                       cin >> choice;

               }

}

void processChoice(int &choice)

{

     int months;           // Number of months

    double charges;       // Monthly charges

    // Process the user's choice

        if (choice != 4)

            {   cout << "For how many months? ";

                  cin >> months;

              

                  // Compute charges based on user input

                  switch (choice)

                  {

            case 1: charges = months * ADULT_RATE;

                    break;

            case 2: charges = months * CHILD_RATE;

                    break;

            case 3: charges = months * SENIOR_RATE;

                  }

                // Display the monthly charges

                cout << fixed << showpoint << setprecision(2);

                cout << "The total charges are $" << charges << endl;

           }

}

Explanation / Answer


//Please clarify this statement: "Add the code to write new membership accounts to the file "members.txt",


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

// Constants for membership rates
const double ADULT_RATE = 40.0;
const double CHILD_RATE = 20.0;
const double SENIOR_RATE = 30.0;
const double FAMILY_RATE = 60.0; // Modifications
static int c_adult=0,c_child=0,c_senior=0,c_family=0;
void displayMenu();
void verifyChoice(int &);
void processChoice(int &);

int main()
{
int choice; // Menu choice

do
{
displayMenu();
cin >> choice;
verifyChoice(choice);
processChoice(choice);
  
} while (choice != 5); // Loop again if the user did not // Modifications
  
cout<<"Standard Adult Membership processed "<<c_adult<<" times"<<endl;
cout<<"Child Membership processed "<<c_child<<" times"<<endl;
cout<<"Senior Citizen Membership processed "<<c_senior<<" times"<<endl;
cout<<"Family Membership processed "<<c_family<<" times"<<endl;
  
system("pause"); // select choice 5 to quit
return 0;
}
void displayMenu(){
// Display the menu and get the user's choice
cout << " Health Club Membership Menu ";
cout << "1. Standard Adult Membership ";
cout << "2. Child Membership ";
cout << "3. Senior Citizen Membership ";
cout << "4. Family Membership "; // Modifications
cout << "5. Quit the Program "; // Modifications
cout << "Enter your choice: ";

}
void verifyChoice(int &choice)
{
// Validate the menu selection
while ((choice < 1) || (choice > 5))
{
cout << "Please enter 1, 2, 3,4 or 5: "; // Modifications
cin >> choice;
}
}
void processChoice(int &choice)
{
int months; // Number of months
double charges; // Monthly charges
// Process the user's choice
if (choice != 5) // Modifications
{ cout << "For how many months? ";
cin >> months;
  
// Compute charges based on user input
switch (choice)
{
case 1: {charges = months * ADULT_RATE;
c_adult++; // Modifications
break;}
case 2: {charges = months * CHILD_RATE;
c_child++; // Modifications
break;}
case 3: {charges = months * SENIOR_RATE;
c_senior++; // Modifications
break;}
case 4: {charges = months * FAMILY_RATE;
c_family++;} // Modifications
}
// Display the monthly charges
cout << fixed << showpoint << setprecision(2);
cout << "The total charges are $" << charges << endl;
}
}