In this tutorial, we’ll code the Gym Management System Project in C++ in a very easy and understandable way. The Gym Management System can be coded using many programming languages, But in this project, we are going to use C++ language as per the demand of students.

What is Gym Management System?

As the name suggests the Gym Management System is a software that handles the entire data of the Gym. It makes the work of a Fitness Manager very easy instead of writing data in a notebook. In past, the gym managers were using notebooks to write the data along with customers’ names who purchased the gym memberships. So it was very difficult to keep track of each and every record.

If a Gym Manager wants to search for a particular gym record then that task was very time-consuming. So to make this task easy the programming languages were developed and the C++ language is one of them.

Features of Gym Management System Project in C++

  • We have created separate logins for the users and the gym managers i.e admin, in which the gym manager is password protected.
  • In this project, the gym manager can add, update, delete and create gym memberships and can assign them to a particular user.
  • The user can quit the gym anytime, whenever he or she wanted.
  • The software gives facility for the users to edit their profiles.
  • Only the admin can delete and edit the membership.
  • During the purchase of membership, the trainer is allotted automatically.
  • This project uses the concept of file handling.

Modules of Gym Management System Project in C++

  • Join Gym.
  • Quit Gym.
  • Edit User Profile.
  • Create Membership
  • Display All Records
  • Search Particular Record
  • Edit Membership Details
  • Delete Membership

Working of Project

After extracting the zip file you’ll get an executable .exe file where you can directly run the entire project manually. This .exe file is also generated after compiling the project using the compiler. Now we’ll see the working of the entire project with proper explanation.

Main Screen:

When you run the project from any compiler or directly click on the executable .exe file you’ll see the following screen shown in the picture.

gym management system project in c++

We’ve displayed the menu of User and the Admin. If you’re a user then your choice will be 1 and if you are a gym manager or admin then your choice will be 2.

Now we’ll discuss each and every menu in detail.

1. User

The user will not require the additional sign-in, he or she will be able to access the software directly.

When the user the choice as 1 then the following screen will appear:

gym management system project in c++

1. Join Gym:

With the help of this menu option, the new users who want to join the gym can register themself. After choosing the options 1st then the software will ask the user to enter the following details:

  • The new member number user wanted.
  • Name of the new member.
  • Phone number.
  • Gold or Silver membership.
  • Preferred time slot.

After entering all the above information the trainer will get allotted to the user and also the registration will be done successfully.

2. Quit Gym:

If the user’s mind changes or the user wanted to change the gym then he or she can quit the gym anytime by choosing the menu option 2. After choosing menu option 2 the software will ask you to enter the member number. And in a fraction of a few seconds, the member will be deleted from the software.

3. Edit your Profile:

This software comes with a unique facility, where the users are able to edit their profiles. If the user wants to edit their profile then they should choose the menu option 3. After choosing the menu option 3 the software will ask you to enter your membership number by which the software will fetch all the details from the file. Then the user has to enter all the details that they want to edit. After entering all the information the profile will be successfully updated.

2. Admin

To access the features of the admin menu, He or she will require to sign in using the username “admin” and the password which is “learnprogramo“. We’ve also given the facility to change the password in the Admin menu. Only Admin has rights to change the password.

When the user presses the choice as 2. then the software will ask you to enter the correct password as shown in the following image:

gym management system project in c++

If the password is incorrect the application will show the error of the wrong password. And if the password is correct then the admin menu will be visible to the user where he or she can do the operations displayed in the menu.

The following menu will be visible to the Gym Manager:

admin credentials

1. Create Member:

If the gym manager wants to add a membership for the new joiner then he should select the menu option 1. After selecting 1st option the software will ask admin to enter information such as member number, Name of the member, Enter contact number, Gold or Silver Membership, Preferred time slot. After entering all the information the trainer will be allocated automatically and the record will be added successfully.

2. Display All Records:

If the gym manager wants to display all the records or the memberships then after selecting the 2nd option all the records will be displayed. The information such as Member code, Name, Category, Fee, Contact and the Timings will be displayed.

3. Search Particular Record:

This software comes with the amazing feature such as searching a record in the fraction of seconds. If the gym manager wants to search for a specific record then by choosing the 3rd option he’ll be able to search the record…

4. Edit Member Details:

The admin has all the rights to edit the details of the member user. If the gym manager found some mistake in the member information then by choosing this option he or she will be able to edit all the record of existing user.

5. Delete Member:

If the membership of any specific user ends then their should be facility to delete the membership. So we’ve added functionality of deleting the member record by choosing 5th option. After choosing the 5th option the software will ask admin to enter the member number so that the software can search the specific record to delete. After entering the correct member number the record will be deleted successfully.

Download the Project

By click the following button you can download the zip file of the project which consist of source code and the executable .exe file.

Download

If you need quick project code then please read the following code:

//Learnprogramo - programming made simple
#include<fstream>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<cstring>
#include<cstdlib>
using namespace std;
class alogin
{
	string admin;
	public:
	int adlogin()
	{
		cout<<"enter the admin code"<<endl;
		cin>>admin;
		if(admin=="admin")
		{	
			 int p=getadpassword();
			 if (p==1)
			 {
			 	cout<<"login succesful"<<endl;
			 	return 1;
			 }
		}
		else{
			cout<<"user name not found"<<endl;
			adlogin();
			cout<<"login failed"<<endl;
			return 0;
		}
	}
	int getadpassword();
};	
int alogin::getadpassword()
{
	string pw;
	cout<<"enter the password"<<endl;
	cin>>pw;
	if(pw=="learnprogramo")
	{
		cout<<"WELCOME!!"<<endl;
		return 1;
	}
	else{
		cout<<"entered password is incorrect"<<endl;
		getadpassword();
		return 0;
	}
}
void allotment_gold(int gc,int sc)
{
    if(gc!=0)
    {
        cout<<gc<<endl;
        cout<<"trainer alloted\n";
    }
     else
     {
         cout<<"no trainer available\n";
     }
}
void allotment_silver(int gc,int sc)
{
    if(sc!=0)
    {
        cout<<sc<<endl;
        cout<<"trainer alloted\n";
    }
     else
     {
         cout<<"\nno trainer available\n";
         if(gc!=0)
         {
             cout<<"enter  another class\n";
             allotment_gold(gc,sc);
         }
     }
}
int trainee_allotment(char* c)
{	char class_type[10];
    int i,gold_class=3,silver_class=5;
    strcpy(class_type,c);
           		if((gold_class!=0) || (silver_class)!=0)
                    {
                        if(strcmp(class_type,"gold")==0)
                        {
                            gold_class--;
                            allotment_gold(gold_class,silver_class);
                        }
                        else if(strcmp(class_type,"silver")==0)
                        {
                            silver_class--;
                            allotment_silver(gold_class,silver_class);
                        }
                    }
                    else
                    {
                        cout<<"no traianer availbale\n";
                        return 1;
                    }
}
class member
    {
    	int member_number,j;
    	char mem_name[50], classs[50],timings[50];
    	float fee;
    	
	long int contact;    	
    	public:
     int time_slots()
       {	
			int k;
			cout<<"please select your preferred timings\n press 1 for: morining 6-7\n press 2 for: morning 7-8\npress 3 for:morning 8-9\n";
			cout<<" press 4 for: evening 4-5\npress 5 for:evening 5-6\npress 6 for:evening 6-7\n";
			cin>>k;
			switch(k)
			{
				case 1:strcpy(timings,"6AM-7AM");break;
				case 2:strcpy(timings,"7AM-8AM");break;
				case 3:strcpy(timings,"8AM-9AM");break;
				case 4:strcpy(timings,"4PM-5PM");break;
				case 5:strcpy(timings,"5PM-6PM");break;
				case 6:strcpy(timings,"6PM-7PM");break;
			}
}	
    	void create_mem()
    	{	int k,l,j;
    		cout<<endl<<"Please Enter The member Number: ";
    		cin>>member_number;
    		cout<<endl<<"Please Enter The Name of The member: ";
    		getchar();
    		cin.getline(mem_name ,50);
    		cout<<endl<<"Please Enter The contact number: ";
    		cin>>contact;
    		cout<<"1.gold class\n 2.silver class\n";
		cout<<"enter the choice\n";
		cin>>k;
		switch (k)
		{
			case 1:{strcpy(classs,"gold");
				fee=2500;
				cout<<"your monthly fee would be: "<<fee<<endl;
				l=trainee_allotment(classs);
				}
				break;
			case 2:{strcpy(classs,"silver");
				fee=2000;
				cout<<"your monthly fee would be: "<<fee<<endl;
				l=trainee_allotment(classs);
				}
				break;
		}
		time_slots();
    	}
    	void show_mem()
    	{
    		cout<<endl<<"member code: "<<member_number;
    		cout<<endl<<"Name: "<<mem_name;
    		cout<<endl<<"category: "<<classs;
    		cout<<endl<<"fee: "<<fee;
    		cout<<endl<<"contact: "<<contact;
    		cout<<endl<<"timings: "<<timings<<endl;
    	}
    	int getmem()
    	{
    		return member_number;
    	}
    	float getfee()
    	{
    		return fee;
    	}
    	char* getName()
    	{
    		return mem_name;
    	}
    	float getcontact()
    	{
    		return contact;
    	}
    }; 
    fstream fp;
    member m1;
    void save_member()
    {
    	fp.open("newdata2.dat",ios::out|ios::app);
    	m1.create_mem();
    	fp.write((char*)&m1,sizeof(m1));
    	fp.close();
    	cout<<endl<<endl<<"the member has been succesfully added...";
    	getchar();
    }
    void show_all()
    {
    	system("cls");
    	cout<<endl<<"\t\tRECORDS...";
    	fp.open("newdata2.dat",ios::in);
    	while(fp.read((char*)&m1,sizeof(m1)))
    	{
    		m1.show_mem();
    		getchar();
    	}
    	fp.close();
    	
    }
     void display_record(int num)
    {
    	bool found=false;
    	fp.open("newdata2.dat",ios::in);
    	while(fp.read((char*)&m1,sizeof(m1)))
    	{
    		if(m1.getmem()==num)
    		{
    			system("cls");
    			m1.show_mem();
    			found=true;
    		}
    	}
    	fp.close();
    	if(found == true)
    	cout<<"\n\nNo record found";
    	getchar();
    }
     void edit_member()
    {
    	int num;
    	bool found=false;
    	system("cls");
    	cout<<endl<<endl<<"\tPlease Enter The member number: ";
    	cin>>num;
    	fp.open("newdata2.dat",ios::in|ios::out);
    	while(fp.read((char*)&m1,sizeof(m1)) && found==false)
    	{
    		if(m1.getmem()==num)
    		{
    			m1.show_mem();
    			cout<<"\nPlease Enter The New details of the member: "<<endl;
    			m1	.create_mem();
    			int pos=1*sizeof(m1);
    			fp.seekp(pos,ios::cur);
    			fp.write((char*)&m1,sizeof(m1));
    			cout<<endl<<endl<<"\t Record Successfully Updated...";
    			found=true;
    		}
    	}
    	fp.close();
    	if(found==false)
    		cout<<endl<<endl<<"Record Not Found...";
    	getchar();
    }
    void delete_member()
    {
    	int num;
    	system("cls");
    	cout<<endl<<endl<<"Please Enter The member number: ";
    	cin>>num;
    	fp.open("newdata2.dat",ios::in|ios::out);
    	fstream fp2;
    	fp2.open("Temp2.dat",ios::out);
    	fp.seekg(0,ios::beg);
    	while(fp.read((char*)&m1,sizeof(m1)))
    	{
    		if(m1.getmem()!=num)
    		{
    			fp2.write((char*)&m1,sizeof(m1));
    		}
    	}
    	fp2.close();
    	fp.close();
    	remove("newdata2.dat");
    	rename("Temp2.dat","newdata2.dat");
    	cout<<endl<<endl<<"\tRecord Deleted...";
    	getchar();
    }
     void fnmanage()
    {
    	for(;;)
    	{
    	system("cls");
    	int option;
    	cout<<"\t***********************************************";
    	cout<<"\n\tPress 1 to CREATE MEMBER";
    	cout<<"\n\tPress 2 to DISPLAY ALL RECORDS";
    	cout<<"\n\tPress 3 to SEARCH FOR A PARTICULAR RECORD ";
    	cout<<"\n\tPress 4 to EDIT MEMBER DETAILS";
    	cout<<"\n\tPress 5 to DELETE MEMBER";
    	cout<<"\n\tPress 6 to GO BACK TO MAIN MENU";
    	cout<<"\n\t**********************************************";
    	cout<<"\n\n\tOption: ";
    	cin>>option;
    	switch(option)
    	{
    		case 1: system("cls");
    				save_member();
    				break;
    				
    		case 2: show_all();
    				break;
    				
    		case 3:
    				int num;
   				system("cls");
    				cout<<"\n\n\tPlease Enter The member Number: ";
    				cin>>num;
    				display_record(num);
    				break;
    				
    		case 4: edit_member();
    			break;
    		
    		case 5: delete_member();
    		        break;
   				
    		case 6: system("cls");
    				break;
    		
    		default:fnmanage();
    		}
    	}
    }
void fitness()
{
	{cout<<"displaying fitness tips..."<<endl;
			std::ifstream f("tips.txt");
  
			if (f.is_open())
		        {
				std::cout << f.rdbuf();
		        }}
}
void fnuser()
{	
	for(;;){
	int m;
	cout<<"1.join gym\n2.quit gym\n3.edit your profile\n";
	cout<<endl<<"enter your choice"<<endl;
	cin>>m;
	switch(m)
	{
		case 1:system("cls");
    				save_member();
    				break;
    		case 2:delete_member();
    		        break;
    		//case 3:fitness();
    		//	break;
    		case 3:edit_member();
    		       break;
	}
}
}
int main()
{
		int i,k;
		string name,code;
		cout<<"Gym Management System Project in C++"<<endl;
		cout<<endl<<"SELECT MODE"<<endl<<"1.User"<<endl<<"2.Admin"<<endl;
		cin>>i;
			if(i==1){cout<<endl<<"you're in user mode"<<endl;
					fnuser();
					}
			if(i==2){cout<<endl<<"you're in admin mode"<<endl;	
					alogin ad;
					k=ad.adlogin();
					if(k==1)
					{
						fnmanage();
					}
					else
					{
						cout<<"you cannot access manageral details!";
					}
					}
		return 0;
}

Steps to Run the Project

  1. Extract the Downloaded Zip file or copy the above source code.
  2. Open the file using C++ Compiler such as Dev C++ etc.
  3. paste the source code and save the file in any of the computer locations.
  4. Compile the project using compile option.
  5. There is no error in the source code, if found then correct it.
  6. Now run the project.
  7. The executable .exe file will be generated in the location you choose.

Summary:

In this way, we’ve created and executed the Gym Management System Project in C++. If you have any doubt then please feel free to contact us. We’ll solve your doubts as soon as possible.

Thanks and HAPPY CODING 🙂

Also Read: