Fitness Tracker App Using Java Swing

Introduction:

The Health and Fitness Tracker is a Java GUI application designed to assist users in monitoring their daily physical activities and maintaining a healthy lifestyle. This application allows users to track important fitness metrics such as steps taken, distance covered, and calories burned. By offering an intuitive graphical interface, users can easily input and visualize their progress over time, helping them stay motivated and focused on their fitness goals.

Key Features:

  1. User Profile: Users can create personalized profiles by entering their basic information such as age, gender, weight, and height. This information is used to calculate accurate calorie burn estimates.

  2. Activity Tracking: The application enables users to input their daily activities, including the number of steps taken and distance covered. Users can also record different types of physical exercises they engage in.

  3. Calories Burned Calculation: The application calculates an estimate of calories burned based on the user’s profile and the input activity data. This helps users understand the impact of their activities on their overall health.

  4. Progress Visualization: The app provides graphical representations of the user’s daily, weekly, and monthly progress. This includes visualizations of steps, distance, and calories burned, helping users track trends and set new goals.

  5. Goal Setting: Users can set fitness goals, such as a target number of steps or calories burned per day. The application provides notifications and visual indicators to motivate users to reach their goals.

  6. Data Storage: The application stores activity data and user profiles, allowing users to review their historical data and analyze their long-term progress.

Source Code:

				
					import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class FitnessTrackerApp extends JFrame {
    private JTextField stepsField;
    private JTextField distanceField;
    private JButton trackButton;
    private JLabel resultLabel;

    public FitnessTrackerApp() {
        setTitle("Health and Fitness Tracker");
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setSize(300, 200);

        stepsField = new JTextField(10);
        distanceField = new JTextField(10);
        trackButton = new JButton("Track Activity");
        resultLabel = new JLabel();

        trackButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                int steps = Integer.parseInt(stepsField.getText());
                double distance = Double.parseDouble(distanceField.getText());
                
                // Perform calculations to estimate calories burned
                double caloriesBurned = calculateCaloriesBurned(steps, distance);
                
                // Display the results to the user
                resultLabel.setText("Calories Burned: " + caloriesBurned);
            }
        });

        JPanel inputPanel = new JPanel(new GridLayout(3, 2));
        inputPanel.add(new JLabel("Steps taken:"));
        inputPanel.add(stepsField);
        inputPanel.add(new JLabel("Distance (km):"));
        inputPanel.add(distanceField);
        inputPanel.add(new JLabel());
        inputPanel.add(trackButton);

        JPanel resultPanel = new JPanel();
        resultPanel.add(resultLabel);

        add(inputPanel, BorderLayout.CENTER);
        add(resultPanel, BorderLayout.SOUTH);
    }

    // Method to calculate estimated calories burned
    private double calculateCaloriesBurned(int steps, double distance) {
        // Simplified calculation; you can implement a more accurate formula
        double caloriesPerStep = 0.04; // Sample value, modify accordingly
        double caloriesPerDistance = 0.1; // Sample value, modify accordingly
        
        return (steps * caloriesPerStep) + (distance * caloriesPerDistance);
    }

    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                new FitnessTrackerApp().setVisible(true);
            }
        });
    }
}

				
			

Output:

Find More Projects

Hostel Management System Using Python With Source Code by using Python Graphical User Interface GUI Introduction: Managing a hostel efficiently can be …

Contra Game Using Python with source code using Pygame Introduction: Remember the super fun Contra game where you fight aliens and jump …

Restaurant Billing Management System Using Python with Tkinter (Graphical User Interface) Introduction: In the bustling world of restaurants, efficiency is paramount, especially …

Jungle Dash Game Using Python with source code with pygame module Introduction: Dive into the excitement of jungle adventures with our new …

Building a Tetris Game with Python with source code Introduction: Welcome to the world of Tetris, where falling blocks meet strategic maneuvers …

Super Mario Game Using Python with source code Introduction: Remember playing Super Mario as a kid? It’s that classic game where you …

All Coding Handwritten Notes

Browse Handwritten Notes