Create this program as a GUI program The cost to become a member of a fitness ce
ID: 3850409 • Letter: C
Question
Create this program as a GUI program
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 in advance, the discount is 15%; or (c) if more than 5 personal
training sessions are purchased, the discount on each session is 20%.
Write a menu driven program that determines the cost of a new membership.
Your program must contain a method that displays the general information about
the fitness center and its charges, a method to get all the necessary information
to determine the membership cost, and a method to determine the membership
cost. Use appropriate parameters to pass information in and out of a method.
Then you need to get the input from the user , using JTextField for the input, Jlabel to describe what you want them to input and some buttons. (Calculate, Exit)
1. The user can choose 1 or 2 (Yes, No) for Senior or it can be a yes or no input.
2. Have the user enter number of months, or you can give them choices. 6, 12, 18 month options.
3. Have the user enter number of training sessions they wish to purchase.
Finally, when the user clicks on the Calculate button. You will show their membership cost
please make sure its a GUI method
Explanation / Answer
#include <iostream>
#include <iomanip>
#include <cstdlib>
using namespace std;
void displayInfo();
int readData();
int memCost(int, int, int);
//the main function
int main ()
{
int cost;
displayInfo();
cost = readData();
cout << "The cost of the membership is :$" << cost << endl;
system ("PAUSE");
return 0;
}
//the display function
void displayInfo()
{
cout<<" Fitness Center - General Information " << endl;
cout<<"Membership for month: $20 ";
cout<<"Personal training sessions: $15 ";
cout<<"Discount for Senior citizens: 30% ";
cout<<"Discount for purchasing 12 or more months 15% ";
cout<<"Discount for purchasing 5 or more personal training sessions 20% ";
}
//the read data function
int readData ()
{
int srCitizen, proChoice, months, sessions, cost;
cout<<"Enter your purchase details... ";
cout<<"Enter 1 if you are a senior citizen or 0 if not : ";
cin>>srCitizen;
if(srCitizen != 1)
{
srCitizen =0;
cout<<" Choose your fitness program... ";
cout<<"1. Monthly membership ";
cout<<"2. Personal Training ";
cout<<" Enter your choice : ";
}
do
{
cin>>proChoice;
if (proChoice<1 || proChoice>2)
cout<<"Enter a valid choice :";
}
while(proChoice<1 || proChoice>2);
if(proChoice==1)
{
cout<<"Enter number of months you want : ";
cin>>months;
}
if(proChoice==2)
{
cout<<"Enter number of sessions you want : ";
cin>>sessions;
cost = memCost(srCitizen, months, sessions);
}
return cost;
}
//the memCost function
int memCost(int srCitizen, int months, int sessions)
{
int cost;
if(sessions<=5)
{
cost = sessions*20;
}
else
{
cost = sessions - (sessions * 0.20);
}
if(months<=12)
{
cost = months * 20;
}
else
{
cost = months * (months * 0.15);
}
if(srCitizen==1)
{
cost = cost - (cost * 0.30);
}
return cost;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.