DEV Community

Cover image for Building a BMI & Body Fat Percentage Calculator with ChatGPT
Atif Khan
Atif Khan

Posted on

Building a BMI & Body Fat Percentage Calculator with ChatGPT

As developers, we often look for projects that are both practical and good learning experiences. Recently, I built a BMI & Body Fat Percentage Calculator with the help of ChatGPT.

This tool lets users calculate their Body Mass Index (BMI) and body fat percentage instantly, and it’s live on my website: bmikalkulatorr.com.

While health and fitness might seem outside the core world of coding, projects like these are a great way to practice working with formulas, input handling, and user experience design.


Why I Built It

  • I wanted to create a tool that’s simple, accurate, and useful in daily life.
  • It was a chance to learn how AI (ChatGPT) can assist in writing logic and formulas.
  • I also wanted to share it with the community, since open knowledge and collaboration are the heart of DEV.

How the Calculator Works

The tool takes four inputs from the user:

  • Height (in inches)
  • Weight (in kilograms)
  • Age (in years)
  • Gender (male/female)

From there, it calculates:

  • BMI Value & Category
  • Body Fat Percentage & Category

The Core Formulas

BMI Calculation:

$$
BMI = \frac{weight \ (kg)}{height^2 \ (m^2)}
$$

Body Fat Percentage (Adults):

  • Male: (1.20 × BMI) + (0.23 × Age) - 16.2
  • Female: (1.20 × BMI) + (0.23 × Age) - 5.4

Body Fat Percentage (Teens):

  • Male: (1.51 × BMI) - (0.70 × Age) - 2.2
  • Female: (1.51 × BMI) - (0.70 × Age) + 1.4

Example Run

Input:

  • Height: 72 inches
  • Weight: 80 kg
  • Age: 30 years
  • Gender: Male

Output:

  • BMI: 23.9Normal Weight
  • Body Fat %: 19.4%Average

Lessons Learned

  • AI as a Coding Partner: ChatGPT helped speed up development by generating boilerplate code and formula logic.
  • Math in Code: Projects like this are great practice for working with real-world equations.
  • Practical Impact: Even a small program can be genuinely useful to people outside the dev community.

Try It Out

👉 You can try the live version here: BMI & Body Fat Calculator


Final Thoughts

As developers, we often build tools just for fun or practice, but sometimes those projects turn into something practical and helpful.

This calculator is my way of combining learning, coding, and sharing knowledge with the wider community. If you’re interested, check out my project — and maybe try building your own version with a different tech stack!

Happy coding ❤️

Top comments (0)