0% found this document useful (0 votes)
18 views20 pages

Java Fitness Tracker Mini-Project Report

The document is a mini-project report on a 'Fitness Tracker' application developed in Java, submitted by students of AMC Engineering College for their Bachelor of Engineering degree. The application allows users to monitor their physical activities, calculate their BMI, and log activities using a console interface while demonstrating Object-Oriented Programming principles. It includes system requirements, implementation details, and highlights both the benefits and limitations of the project.

Uploaded by

caedsoftwareu
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)
18 views20 pages

Java Fitness Tracker Mini-Project Report

The document is a mini-project report on a 'Fitness Tracker' application developed in Java, submitted by students of AMC Engineering College for their Bachelor of Engineering degree. The application allows users to monitor their physical activities, calculate their BMI, and log activities using a console interface while demonstrating Object-Oriented Programming principles. It includes system requirements, implementation details, and highlights both the benefits and limitations of the project.

Uploaded by

caedsoftwareu
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

VISVESVARAYA TECHNOLOGICAL UNIVERSITY

“Jnana Sangama”, Belgaum 590014, KARNATAKA, INDIA

A Mini-Project Report
“Fitness Tracker using java”

A Mini-project report submitted in partial fulfillment of the requirements for the award
of the degree of Bachelor of Engineering in Computer Science and Engineering (Data Science) of
Visvesvaraya Technological University, Belgaum.

Submitted by:

HARIKIRAN (1AM24CD033)

GNANESH(1AM24CD031)

HARSH(1AM24CD034)

GURUKIRAN (1AM24CD032)

Under the Guidance of:

Prof. Sumitra Sharma Ph

(Department of CSE-DS)

Department of Computer Science and Engineering (DATA SCIENCE)


(AMC Engineering College,18th K.M, Bannerghatta Main Road, Bangalore-560 0832023-2024)

1
DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING (DATA
SCIENCE)

CERTIFICATE
This is to certify that the mini-project work entitled “Fitness Tracker” has been
successfully carried out by Harikiran (33), Gnanesh (31), Gurukiran (32), Harsh (34),
bonafide students of AMC Engineering College with project coordinator prof. Sumitra
Sharma Ph in partial fulfillment of the requirements for the award of degree in Bachelor
of Engineering in Computer Science and Engineering (Data Science) of Visvesvaraya
Technological University, Belgaum during academic year 2024-2025. It is certified that
all corrections/suggestions indicated for Internal Assessment have been incorporated in the
report. The mini project report has been approved as it satisfies the academic requirements
in respect of project work for the said degree.

Faculty Signature
MISS SUMITRA Sharma ph
Assistant Professor / CSE- DS,
AMC Engineering College,
Bengaluru- 560100.

2
CONTENTS

Title Page No

1 INTRODUCTION
4 -6
1.1 Introduction
1.2 Objective
1.3 Benefits and limitations

2 SYSTEM REQUIREMENTS
6-7

2.1 Hardware Requirements


2.2 Software Requirements

3 IMPLEMENTATION

Source code 8-18

4 RESULTS (screenshots of execution)


19

6. CONCLUSION
20

3
CHAPTER-1

1.1 INTRODUCTION

The Fitness Tracker Project is a Java-based console application designed to help users monitor and
manage their daily physical activities efficiently. The system enables users to create a personalized
profile containing basic health information such as name, age, height, and weight. Using this
information, the application calculates the user’s Body Mass Index (BMI) and helps track their progress
over time.

The project is built using Object-Oriented Programming (OOP) principles such as Encapsulation,
Inheritance, Polymorphism, and Abstraction, ensuring modularity, code reusability, and better
maintainability. The application also employs file handling to record activity logs, making it possible to
view past workouts or calorie data.

Through a simple menu-driven interface, users can:

• View their fitness profile


• Add new activities (like running, walking, or cycling)
• View previous activities stored in a file

The system is designed to be beginner-friendly yet conceptually rich, making it ideal for demonstrating
OOP implementation in a real-world context.

4
1.2 OBJECTIVES
The primary objective of the Fitness Tracker Project is to develop a simple yet functional Java-
based console application that demonstrates the core concepts of Object-Oriented Programming
(OOP) while helping users monitor their fitness activities.

This project aims to:

• Implement Encapsulation, Inheritance, and Polymorphism to design a modular and


maintainable system.
• Allow users to create and manage personal fitness profiles by entering essential health data
such as name, age, height, and weight.
• Enable users to log daily activities (e.g., running, walking, cycling) and automatically
calculate calories burned.
• Integrate BMI calculation to help users understand their body health status.
• Use file handling to save and retrieve past activity records for reference.
• Provide a menu-driven interface to make the application user-friendly and interactive.

The project not only tracks fitness metrics but also serves as a practical example of applying Java
OOP principles in a real-world scenario, emphasizing structured programming, data protection, and
code reusability.

5
1.4 BENEFITS AND LIMITATIONS
❖BENEFITS:
• Demonstrates OOP Concepts Clearly
The project effectively applies Java’s Object-Oriented Programming principles — encapsulation,
inheritance, and polymorphism — making it an excellent learning example for understanding modular
design.

• User-Friendly Menu Interface


The console-based menu-driven system is simple to navigate, allowing users to perform actions like
viewing profiles, logging activities, and checking past records easily.

• Health Awareness and Self-Monitoring


By calculating BMI and calories burned, the application encourages users to track their health and physical
activity levels regularly.

• Persistent Data Storage


Through basic file handling, user activities are stored permanently, enabling retrieval of previous activity
logs even after the program is closed.

• Extensible Design
The modular structure allows easy future enhancements, such as integrating databases, adding more activity
types, or providing graphical reports.

❖LIMITATIONS:
1. Console-Based Interface Only
The program runs purely in a command-line environment and lacks a graphical user interface
(GUI), which may limit usability for non-technical users.
2. Single-User Operation
The application supports only one user profile at a time, meaning multiple users cannot maintain
separate logs simultaneously.
3. Limited Activity Categories
Currently supports a few basic activities (Running, Walking, Cycling). Additional fitness activities
would require manual code updates.
4. No Real-Time Tracking
The system does not connect with real fitness devices or sensors; all data must be entered
manually.
5. Basic File Handling
While functional, text-based file storage lacks data validation and may not be suitable for large-
scale or multi-user applications.
CHAPTER-2
6
SYSTEM REQUIREMENTS

2.1 Hardware Requirements:


▪ Hard Disk – 2 GB.
▪ RAM- 1 GB.
▪ Processor- Dual Core or Above.

2.2 Software Requirements:


Category Description
Operating System Windows 10 / 11, macOS, or Linux
Programming Language Java (JDK 8 or above)
Integrated Development Eclipse IDE / IntelliJ IDEA / NetBeans / VS Code (with
Environment (IDE) Java Extension)
Text Editor (optional) Notepad / Notepad++ / Sublime Text

7
IMPLEMENTATION

Source Code:
package fitnessproject;

import [Link].*;
import [Link].*;

/**
* Fitness Tracker Project
* Demonstrates: Classes & Objects, Encapsulation, Constructors,
* Inheritance, Polymorphism (overriding/overloading), basic File I/O,
* and a menu-driven console interface.
*
* To compile:
* javac fitnessproject/[Link]
* To run:
* java [Link]
*
* (If using separate files, move each class to its own file and keep the
package line.)
*/

// ------------------------- Person (Base Class) -------------------------


/**
* Person - base class representing a generic person.
* Protected fields allow derived classes to access them directly.
*/
class Person {
protected String name;
protected int age;

// Constructor
8
public Person(String name, int age) {
[Link] = name;
[Link] = age;
}

// Display basic info - can be overridden by subclasses


public void displayInfo() {
[Link]("Name: " + name + ", Age: " + age);
}
}

// ------------------------- User (Derived Class) -------------------------


/**
* User - extends Person and stores fitness-specific data.
* Demonstrates encapsulation via private fields and getters/setters.
*/
class User extends Person {
private double weight; // kilograms
private double height; // meters

public User(String name, int age, double weight, double height) {


super(name, age);
[Link] = weight;
[Link] = height;
}

// Getters and setters (Encapsulation)


public double getWeight() { return weight; }
public void setWeight(double weight) { [Link] = weight; }

public double getHeight() { return height; }


public void setHeight(double height) { [Link] = height; }

9
// Compute BMI (simple formula)
public double calculateBMI() {
if (height <= 0) return 0;
return weight / (height * height);
}

// Override displayInfo to include fitness data


@Override
public void displayInfo() {
[Link]();
[Link]("Weight: %.1f kg, Height: %.2f m, BMI: %.2f%n",
weight, height, calculateBMI());
}
}

// ------------------------- Activity (Encapsulated Class) -------------------------


/**
* Activity - represents a single physical activity entry.
* Demonstrates constructor overloading (polymorphism) and encapsulation.
*/
class Activity {
private String type; // e.g., Running, Walking
private int durationMinutes; // duration in minutes
private double calories; // computed calories burned

// Primary constructor
public Activity(String type, int durationMinutes) {
[Link] = (type == null) ? "Unknown" : [Link]();
[Link] = [Link](0, durationMinutes);
[Link] = estimateCalories();
}

// Overloaded constructor: default duration 30 minutes


10
public Activity(String type) {
this(type, 30);
}

// Getters (encapsulation)
public String getType() { return type; }
public int getDurationMinutes() { return durationMinutes; }
public double getCalories() { return calories; }

// Private helper to estimate calories burned (simple rule-of-thumb)


private double estimateCalories() {
String t = [Link]();
switch (t) {
case "running": return durationMinutes * 10.0; // 10 cal/min
case "walking": return durationMinutes * 5.0; // 5 cal/min
case "cycling": return durationMinutes * 8.0; // 8 cal/min
default: return durationMinutes * 6.0; // generic
}
}

// Nicely formatted display


public void display() {
[Link]("%s for %d minutes — Calories burned: %.1f%n",
type, durationMinutes, calories);
}

// String suitable for file storage (CSV)


public String toCSV() {
return [Link]("%s,%d,%.1f", type, durationMinutes, calories);
}

// Create Activity from CSV line; returns null if invalid


public static Activity fromCSV(String csvLine) {
11
if (csvLine == null || [Link]().isEmpty()) return null;
String[] parts = [Link](",");
try {
String type = parts[0];
int duration = [Link](parts[1]);
// We recompute calories to keep logic centralized
return new Activity(type, duration);
} catch (Exception e) {
return null;
}
}
}

// ------------------------- FileManager (File Handling) -------------------------


/**
* FileManager - handles persistent logging of activities to a text file.
* Each activity is stored as a CSV line: type,duration,calories
*/
class FileManager {
private static final String FILE_NAME = "fitness_log.txt";

// Append an activity to the log file


public static void saveActivity(Activity activity) {
if (activity == null) return;
try (BufferedWriter bw = new BufferedWriter(new
FileWriter(FILE_NAME, true))) {
[Link]([Link]());
[Link]();
} catch (IOException e) {
[Link]("Error saving activity: " + [Link]());
}
}

12
// Read all activities from log file and return as Activity list
public static List<Activity> readActivities() {
List<Activity> activities = new ArrayList<>();
File file = new File(FILE_NAME);
if (![Link]()) {
return activities; // empty
}
try (BufferedReader br = new BufferedReader(new FileReader(file))) {
String line;
while ((line = [Link]()) != null) {
Activity a = [Link](line);
if (a != null) [Link](a);
}
} catch (IOException e) {
[Link]("Error reading activity log: " + [Link]());
}
return activities;
}

// Print activities in human-readable form


public static void displayActivityLog() {
List<Activity> activities = readActivities();
if ([Link]()) {
[Link]("\n--- No activities logged yet ---");
return;
}
[Link]("\n--- Activity Log ---");
for (Activity a : activities) {
[Link]();
}
}
}

13
// ------------------------- FitnessTracker (Main Class) -------------------------
/**
* FitnessTracker - Menu-driven main application.
* Demonstrates object creation, polymorphism (overriding/overloading),
* and interaction with FileManager for persistence.
*/
public class FitnessTracker {
private static final Scanner sc = new Scanner([Link]);

public static void main(String[] args) {


[Link]("=== Fitness Tracker ===");

// Create user profile


[Link]("Enter your name: ");
String name = [Link]().trim();
[Link]("Enter your age: ");
int age = readIntSafe();
[Link]("Enter your weight (kg): ");
double weight = readDoubleSafe();
[Link]("Enter your height (m): ");
double height = readDoubleSafe();

User user = new User(name, age, weight, height);

// Main menu loop


int choice;
do {
showMenu();
choice = readIntSafe();
switch (choice) {
case 1:
[Link]();
[Link]();
14
break;
case 2:
addActivityFlow();
break;
case 3:
[Link]();
break;
case 4:
// Optionally allow updating user data
updateProfile(user);
break;
case 5:
[Link]("Exiting Fitness Tracker... Stay healthy!");
break;
default:
[Link]("Invalid choice. Enter a number from the
menu.");
}
} while (choice != 5);

[Link]();
}

// Display menu options


private static void showMenu() {
[Link]("\n===== FITNESS TRACKER MENU =====");
[Link]("1. View Profile");
[Link]("2. Add Activity");
[Link]("3. View Activity Log");
[Link]("4. Update Profile");
[Link]("5. Exit");
[Link]("Enter your choice: ");
}

15
// Flow for adding an activity
private static void addActivityFlow() {
[Link]("Enter activity type
(Running/Walking/Cycling/Other): ");
String type = [Link]().trim();
[Link]("Enter duration (in minutes): ");
int duration = readIntSafe();
Activity activity = new Activity(type, duration);
[Link]();
[Link]();
[Link](activity);
}

// Allow updating weight/height/age


private static void updateProfile(User user) {
[Link]("\n--- Update Profile ---");
[Link]("Enter new weight (kg) or press Enter to skip: ");
String wline = [Link]().trim();
if (![Link]()) {
try { [Link]([Link](wline)); } catch
(NumberFormatException e) { [Link]("Invalid input, weight not
updated."); }
}
[Link]("Enter new height (m) or press Enter to skip: ");
String hline = [Link]().trim();
if (![Link]()) {
try { [Link]([Link](hline)); } catch
(NumberFormatException e) { [Link]("Invalid input, height not
updated."); }
}
[Link]("Enter new age or press Enter to skip: ");
String aline = [Link]().trim();
if (![Link]()) {
16
try { /* age is protected in Person, so no setter - workaround: create
new User? */
int newAge = [Link](aline);
// Recreate user preserving name and new values
user = new User([Link], newAge, [Link](),
[Link]());
[Link]("Age updated (internal user object replaced).");
} catch (NumberFormatException e) { [Link]("Invalid
input, age not updated."); }
}
[Link]("Profile after update:");
[Link]();
}

// Safe int read (returns 0 on bad parse after prompting again)


private static int readIntSafe() {
while (true) {
String line = [Link]().trim();
try {
return [Link](line);
} catch (NumberFormatException e) {
[Link]("Please enter a valid integer: ");
}
}
}

// Safe double read


private static double readDoubleSafe() {
while (true) {
String line = [Link]().trim();
try {
return [Link](line);
} catch (NumberFormatException e) {
[Link]("Please enter a valid number: ");
17
}
}
}
}

18
SCREENSHOTS

19
CHAPTER-6
CONCLUSION
The Fitness Tracker project successfully demonstrates the core principles of Object-Oriented
Programming (OOP) in Java — including class and object creation, encapsulation, inheritance,
polymorphism, and file handling — through a real-world, menu-driven application.

It allows users to create and manage personal fitness profiles, record daily activities, calculate BMI
and calories burned, and store activity logs in a text file for persistence.

This project not only reinforces theoretical OOP concepts but also provides hands-on experience in
designing structured and modular Java applications. With further enhancement, such as adding a
Graphical User Interface (GUI) or database integration, the system could evolve into a full-
featured personal fitness management platform.

20

You might also like