Skip to content

Assignment 1 #317

@mustafaahmadi015-spec

Description

@mustafaahmadi015-spec

#include
using namespace std;

// 1. UserProfile Class
class UserProfile {
private:
string name;
int age;
float weight;

public:
// Parameterized Constructor
UserProfile(string n, int a, float w) {
name = n;
age = a;
weight = w;
}

// Getters
string getName() {
    return name;
}

int getAge() {
    return age;
}

float getWeight() {
    return weight;
}

// Setters (only age and weight)
void setAge(int a) {
    age = a;
}

void setWeight(float w) {
    weight = w;
}

};

// 2. DailyActivity Class
class DailyActivity {
private:
int steps;
float distance;
float caloriesBurned;

public:
// Default Constructor
DailyActivity() {
steps = 0;
distance = 0;
caloriesBurned = 0;
}

// Setters
void setSteps(int s) {
    steps = s;
}

void setDistance(float d) {
    distance = d;
}

void setCalories(float c) {
    caloriesBurned = c;
}

// Getters
int getSteps() {
    return steps;
}

float getDistance() {
    return distance;
}

float getCalories() {
    return caloriesBurned;
}

};

// 3. HealthReport Class
class HealthReport {
private:
float BMI;
string activityStatus;

public:
// Constructor
HealthReport(UserProfile user, DailyActivity activity) {
float height = 1.7; // fixed height

    // BMI Calculation
    BMI = user.getWeight() / (height * height);

    // Activity Status
    if (activity.getSteps() >= 10000) {
        activityStatus = "Active";
    } else {
        activityStatus = "Low Activity";
    }
}

// Getters
float getBMI() {
    return BMI;
}

string getActivityStatus() {
    return activityStatus;
}

};

// Main Function
int main() {

// Create UserProfile object
UserProfile user("Mustafa", 20, 65.5);

// Create DailyActivity object
DailyActivity activity;

// Set activity data
activity.setSteps(12000);
activity.setDistance(5.5);
activity.setCalories(300);

// Create HealthReport object
HealthReport report(user, activity);

// Display Output
cout << "User Name: " << user.getName() << endl;
cout << "Age: " << user.getAge() << endl;
cout << "Weight: " << user.getWeight() << endl;

cout << "\nDaily Activity:" << endl;
cout << "Steps: " << activity.getSteps() << endl;
cout << "Distance: " << activity.getDistance() << " km" << endl;
cout << "Calories Burned: " << activity.getCalories() << endl;

cout << "\nHealth Report:" << endl;
cout << "BMI: " << report.getBMI() << endl;
cout << "Activity Status: " << report.getActivityStatus() << endl;

return 0;

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions