Question

In: Computer Science

(IN C LANGUAGE) The cost to become a member of a fitness center is as follows:...

(IN C LANGUAGE) The cost to become a member of a fitness center is as follows:

(a) the senior citizens discount is 30%

(b) if the membership is bought and paid for 12 or more months, the discount is 15%

(c) if more than five personal training sessions are bought and paid for, the discount on each session is 20%

Write a that determines the cost of a new membership.

Your program must contain: a function that displays the general information about the fitness center and its charges a function that prompts for the price per month of a membership and the cost of each personal trainer session

a function that prompts for all of the necessary information to determine the cost of a membership

a function to determine the membership cost

STARTER CODE:

#include <stdio.h>
#include <stdbool.h>

void setPrices(...);

void getInfo(...);
double membershipCost(...);
void displayCenterInfo();


int main()
{
}

void displayCenterInfo()
{
   printf("Welcome to Stay Healty and Fit center.\n");
   printf("This program determines the cost of a new membership.\n");
   printf("If you are a senior citizen, then the discount is 30%% of the regular membership price.\n");
   printf("If you buy membership for twelve months and pay today, the discount is 15%%.\n");
   printf("If you buy and pay for 6 or more personal training session today, the discount on each session is 20%%.\n\n");
}

Solutions

Expert Solution

// sourceCode.c

#include <stdio.h>

#include <stdbool.h>

void setPrices(double*, double*);

void getInfo(bool*, bool*, bool*, int*, int*);

double membershipCost(double, int, double, int, bool, bool, bool);

void displayCenterInfo();


int main()

{

    bool seniorCitizen;

    bool boughtSixOrMoreSessions;

    bool paidTwelveOrMoreMonths;

    int numberOfMembershipMonths;

    int numberOfPersonalTrainingSessions;

    double regularMembershipChargesPerMonth;

    double costOfOnePersonalTrainingSession;

    double memberCost;

    displayCenterInfo();

    // Note: & is used to pass the variable as by reference to the function

    setPrices(&regularMembershipChargesPerMonth, &costOfOnePersonalTrainingSession);

    getInfo(&seniorCitizen, &boughtSixOrMoreSessions, &paidTwelveOrMoreMonths, &numberOfMembershipMonths, &numberOfPersonalTrainingSessions);

    // calculate getInfo

    memberCost = membershipCost(regularMembershipChargesPerMonth, numberOfMembershipMonths, costOfOnePersonalTrainingSession,

                                 numberOfPersonalTrainingSessions, seniorCitizen, boughtSixOrMoreSessions, paidTwelveOrMoreMonths);

    printf("$%.2lf\n",memberCost);

    return 0;

}


void displayCenterInfo()

{

   printf("Welcome to Stay Healthy and Fit center.\n");

   printf("This program determines the cost of a new membership.\n");

   printf("If you are a senior citizen, then the discount is 30%% of the regular membership price.\n");

   printf("If you buy membership for twelve months and pay today, the discount is 15%%.\n");

   printf("If you buy and pay for 6 or more personal training session today, the discount on each session is 20%%.\n\n");

}


void setPrices(double* regMemPrice, double* personalTrSesCost)

{

    printf("Please enter the cost of regular Membership per month: ");

    scanf("%lf",&*regMemPrice);

    printf("Please enter the cost of one personal training session: ");

    scanf("%lf",&*personalTrSesCost);

}


void getInfo(bool* senCitizen, bool* bSixOrMoreSess, bool* paidTwMnth, int* nOfMonths, int* nOfPersonalTrSess)

{

    //Senior Citizen Verification

    char userInputSenior;

    printf("Are you Senior? Please enter 'Y' or 'N': ");

    scanf(" %c",&userInputSenior);

    if (userInputSenior == 'y' || userInputSenior == 'Y') {

        *senCitizen = true;

    } else{

        *senCitizen = false;

    }


    //Number of personal training session.

    printf("Enter the number of personal training sessions bought: ");

    scanf("%d",&*nOfPersonalTrSess);

    if (*nOfPersonalTrSess > 5){

        *bSixOrMoreSess = true;

    }

    else{

        *bSixOrMoreSess = false;

    }


    //Number of months

    printf("Enter the number of months you are paying for: ");

    scanf("%d",&*nOfMonths);

    if (*nOfMonths >= 12){

        *paidTwMnth = true;

    } else{

        *paidTwMnth = false;

    }

}


double membershipCost(double regMemPricePerMth, int nOfMonths, double personalTrSesCost, int nOfPersonalTrSess,

                       bool senCitizen, bool bSixOrMoreSess, bool paidTwMnth)

{

    double finalMembershipCost, finalSessionCost;

    //Session Discount

    if (bSixOrMoreSess) {

        personalTrSesCost = (personalTrSesCost * 0.8);

    } else {

        personalTrSesCost = personalTrSesCost;

    }

    //Month Discount

    if (paidTwMnth) {

        regMemPricePerMth = regMemPricePerMth * 0.85;

    } else {

        regMemPricePerMth = regMemPricePerMth;

    }

    finalMembershipCost = regMemPricePerMth * nOfMonths;

    finalSessionCost = personalTrSesCost * nOfPersonalTrSess;


    // Check if Senior Citizen Discount Applies

    if (senCitizen) {

        return (finalMembershipCost * 0.7) + finalSessionCost;

    } else {

        return finalMembershipCost + finalSessionCost;

    }

}

// Screenshots:

// Output:

// If you found the answer helpful do give a Thumbs Up!!


Related Solutions

C Code The cost to become a member of a fitness center is as follows: (a)...
C Code The cost to become a member of a fitness center is as follows: (a) the senior citizens discount is 30% (b) if the membership is bought and paid for 12 or more months, the discount is 15% (c) if more than five personal training sessions are bought and paid for, the discount on each session is 20% Write a that determines the cost of a new membership. Your program must contain: a function that displays the general information...
You are hired to design a database for a fitness center. As the fitness center is...
You are hired to design a database for a fitness center. As the fitness center is expanding with more than one branch, they want to create a database to keep track of its customers, facilities and employees. Each branch has a unique id and address (building number, street, district, and city). A branch may have more than one facility (e.g. swimming pool, spa, etc.). Each facility must belong to only one branch, and the information for a facility is name...
You are hired to design a database for a fitness center. As the fitness center is...
You are hired to design a database for a fitness center. As the fitness center is expanding with more than one branch, they want to create a database to keep track of its customers, facilities and employees. Each branch has a unique id and address (building number, street, district, and city). A branch may have more than one facility (e.g. swimming pool, spa, etc.). Each facility must belong to only one branch, and the information for a facility is name...
Mixed Costs and Cost Formula Callie's Gym is a complete fitness center. Owner Callie Ducain employs...
Mixed Costs and Cost Formula Callie's Gym is a complete fitness center. Owner Callie Ducain employs various fitness trainers who are expected to staff the front desk and to teach fitness classes. While on the front desk, trainers answer the phone, handle walk-ins and show them around the gym, answer member questions about the weight machines, and do light cleaning (wiping down the equipment, vacuuming the floor). The trainers also teach fitness classes (e.g., pilates, spinning, body pump) according to...
Mixed Costs and Cost Formula Callie's Gym is a complete fitness center. Owner Callie Ducain employs...
Mixed Costs and Cost Formula Callie's Gym is a complete fitness center. Owner Callie Ducain employs various fitness trainers who are expected to staff the front desk and to teach fitness classes. While on the front desk, trainers answer the phone, handle walk-ins and show them around the gym, answer member questions about the weight machines, and do light cleaning (wiping down the equipment, vacuuming the floor). The trainers also teach fitness classes (e.g., pilates, spinning, body pump) according to...
In C++ Programming Language: 1a. Declare a class, namely ReverseUniverse, that contains three public member functions....
In C++ Programming Language: 1a. Declare a class, namely ReverseUniverse, that contains three public member functions. Please see Q2 and Q3 for the name of the second and third function. (5 points) Write a function string reverseString that reverses a string (first member function). It takes a string parameter and returns its reversed version. (10 points) 1b. In the class ReverseUniverse in Q1. Write a function vector reverseVector that reverses a vector (second member function). It takes a double vector...
the owner of a fitness center is interested in estimating the difference in mean years that...
the owner of a fitness center is interested in estimating the difference in mean years that female members have been with the club compared with male members. he wishes to develop a 99% confidence interval estimate. The data are showen in the accompanying table. Assuming that the same data are approximately normal and that the two populations have equal variances, develop and interpret the confidence interval estimate. dicuss the results gender 1=male 2=female 1 2 2 2 1 2 2...
The owner of a fitness center is interested in estimating the difference in mean years that...
The owner of a fitness center is interested in estimating the difference in mean years that female members have been with the club compared with male members. He wishes to develop a 95​% confidence interval estimate. The data are shown in the accompanying table. Assuming that the sample data are approximately normal and that the two populations have equal​ variances, develop and interpret the confidence interval estimate. Discuss the result. Gender_(1=Male_2=Female) Years_With_the_Club 2 3.5 2 1 1 3 2 2...
A fitness center is interested in finding a 98% confidence interval for the mean number of...
A fitness center is interested in finding a 98% confidence interval for the mean number of days per week that Americans who are members of a fitness club go to their fitness center. Records of 213 members were looked at and their mean number of visits per week was 3.5 and the standard deviation was 1.8. Round answers to 3 decimal places where possible. a. To compute the confidence interval use a distribution. b. With 98% confidence the population mean...
A fitness center is interested in finding a 98% confidence interval for the mean number of...
A fitness center is interested in finding a 98% confidence interval for the mean number of days per week that Americans who are members of a fitness club go to their fitness center. Records of 251 members were looked at and their mean number of visits per week was 3.1 and the standard deviation was 2.8. Round answers to 3 decimal places where possible. a. To compute the confidence interval use a Z or T distribution? b. With 98% confidence...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT