0% found this document useful (0 votes)
25 views5 pages

Gym Member Management System

The document contains a C++ implementation of a Gym Member Management System that allows for adding, updating, removing, and managing gym members' data, including their height, weight, and BMI calculations. It provides functionalities such as displaying members with maximum and minimum height and weight, calculating average height and weight, and classifying BMI. The program features a simple text-based menu for user interaction.

Uploaded by

nitayhowlader45
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views5 pages

Gym Member Management System

The document contains a C++ implementation of a Gym Member Management System that allows for adding, updating, removing, and managing gym members' data, including their height, weight, and BMI calculations. It provides functionalities such as displaying members with maximum and minimum height and weight, calculating average height and weight, and classifying BMI. The program features a simple text-based menu for user interaction.

Uploaded by

nitayhowlader45
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Gym Member Management System - C++ Code

#include <iostream>
using namespace std;

#define MAX_MEMBERS 300 // Maximum number of gym members

class Member {
public:
int id;
float height; // in meters
float weight; // in kg

void input() {
cout << "Enter Member ID: ";
cin >> id;
cout << "Enter Height (in meters): ";
cin >> height;
cout << "Enter Weight (in kg): ";
cin >> weight;
}

void display() {
cout << "ID: " << id << ", Height: " << height << " m, Weight: " << weight << "
kg\n";
}

float calculateBMI() {
return weight / (height * height);
}
};

class Gym {
Member members[MAX_MEMBERS];
int count;

public:
Gym() {
count = 0;
}

void addMember() {
if (count < MAX_MEMBERS) {
members[count].input();
count++;
cout << "Member added successfully!\n";
} else {
cout << "Gym is full! Cannot add more members.\n";
}
}

void updateMember() {
int id, found = 0;
cout << "Enter Member ID to update: ";
cin >> id;
for (int i = 0; i < count; i++) {
if (members[i].id == id) {
cout << "Enter new details:\n";
members[i].input();
found = 1;
cout << "Member updated successfully!\n";
break;
}
}
if (!found) {
cout << "Member not found!\n";
}
}

void removeMember() {
int id, found = 0;
cout << "Enter Member ID to remove: ";
cin >> id;
for (int i = 0; i < count; i++) {
if (members[i].id == id) {
for (int j = i; j < count - 1; j++) {
members[j] = members[j + 1]; // Shift remaining members
}
count--;
found = 1;
cout << "Member removed successfully!\n";
break;
}
}
if (!found) {
cout << "Member not found!\n";
}
}

void maxHeightWeight() {
if (count == 0) {
cout << "No members available.\n";
return;
}
int maxH = 0, maxW = 0;
for (int i = 1; i < count; i++) {
if (members[i].height > members[maxH].height) maxH = i;
if (members[i].weight > members[maxW].weight) maxW = i;
}
cout << "Member with Max Height:\n";
members[maxH].display();
cout << "Member with Max Weight:\n";
members[maxW].display();
}

void minHeightWeight() {
if (count == 0) {
cout << "No members available.\n";
return;
}
int minH = 0, minW = 0;
for (int i = 1; i < count; i++) {
if (members[i].height < members[minH].height) minH = i;
if (members[i].weight < members[minW].weight) minW = i;
}
cout << "Member with Min Height:\n";
members[minH].display();
cout << "Member with Min Weight:\n";
members[minW].display();
}

void averageHeightWeight() {
if (count == 0) {
cout << "No members available.\n";
return;
}
float totalH = 0, totalW = 0;
for (int i = 0; i < count; i++) {
totalH += members[i].height;
totalW += members[i].weight;
}
cout << "Average Height: " << (totalH / count) << " meters\n";
cout << "Average Weight: " << (totalW / count) << " kg\n";
}

void bmiClassification() {
int id, found = 0;
cout << "Enter Member ID for BMI Classification: ";
cin >> id;
for (int i = 0; i < count; i++) {
if (members[i].id == id) {
float bmi = members[i].calculateBMI();
cout << "BMI of Member ID " << id << " is: " << bmi << "\n";
if (bmi < 16) cout << "Severe Thinness\n";
else if (bmi < 17) cout << "Moderate Thinness\n";
else if (bmi < 18.5) cout << "Mild Thinness\n";
else if (bmi < 25) cout << "Normal\n";
else if (bmi < 30) cout << "Overweight\n";
else if (bmi < 35) cout << "Obese Class I\n";
else if (bmi < 40) cout << "Obese Class II\n";
else cout << "Obese Class III\n";
found = 1;
break;
}
}
if (!found) {
cout << "Member not found!\n";
}
}
};

int main() {
Gym gym;
int option;

while (1) {
cout << "\n******** Main Menu ********\n";
cout << "1. Add Member\n";
cout << "2. Update Member\n";
cout << "3. Remove Member\n";
cout << "4. Max Height & Weight\n";
cout << "5. Min Height & Weight\n";
cout << "6. Average Height & Weight\n";
cout << "7. BMI Classification\n";
cout << "8. Exit\n";
cout << "Enter your option : ";
cin >> option;

if (option == 1) gym.addMember();
else if (option == 2) gym.updateMember();
else if (option == 3) gym.removeMember();
else if (option == 4) gym.maxHeightWeight();
else if (option == 5) gym.minHeightWeight();
else if (option == 6) gym.averageHeightWeight();
else if (option == 7) gym.bmiClassification();
else if (option == 8) {
cout << "Exiting program...\n";
break;
} else {
cout << "Invalid option! Please try again.\n";
}
}

return 0;
}

Sample Output:
******** Main Menu ********
1. Add Member
2. Update Member
3. Remove Member
4. Max Height & Weight
5. Min Height & Weight
6. Average Height & Weight
7. BMI Classification
8. Exit
Enter your option : 1
Enter Member ID: 101
Enter Height (in meters): 1.75
Enter Weight (in kg): 72
Member added successfully!

Enter your option : 7


Enter Member ID for BMI Classification: 101
BMI of Member ID 101 is: 23.51
Normal

Enter your option : 8


Exiting program...

You might also like