Post details: Java Body fat calculator

Monday February 13, 2006

Permalink 06:19:45 pm, by northwind Email , 236 words, 135 views   English (US)
Categories: General

Java Body fat calculator

Well based on the first body density equation from this site.

http://topendsports.com/testing/tests/skinfolds.htm

I have written a Body Fat Percent Calculator in Java that uses skin fold measurements. I could easily make it into a Javascript and post a working version on the site, but I think for now, I'll just post the source code so you can compile it on your own. I have no problem doing that. It seems to be much more accurate than the tape measurement I had previously been using. Let me know if you see any problems with the program.


import java.util.Scanner;
import java.io.IOException;

public abstract class bfcalc {
public static double calc(double chest, double abdominal, double thigh, int age) {
double sum = chest + abdominal + thigh;
double density = (1.10938d - (0.0008267d * sum) + (0.0000016d * (sum * sum)) - (0.0002574d * age));
return (495/density) - 450;
}

public static void main(String[] args) throws IOException{
System.out.print("Enter your age: ");
Scanner in = new Scanner(System.in);
int age = in.nextInt();
in.nextLine();
System.out.print("Enter chest measurement: ");
double chest = in.nextDouble();
in.nextLine();
System.out.print("Enter abdominal measurement: ");
double abdominal = in.nextDouble();
in.nextLine();
System.out.print("Enter thigh measurement: ");
double thigh = in.nextDouble();
in.nextLine();
System.out.println("Your body fat percentage is " + bfcalc.calc(chest, abdominal, thigh, age));
}
}

Oh and by the way. Based on several runs of my program, my body fat percent is 15.33 ± 0.57. :D

Permalink

Comments, Pingbacks:

No Comments/Pingbacks for this post yet...

blog dot northwindy dot com

Welcome to blog dot northwindy dot com... try not to mess anything up hehe...

Visit Northwindy.com
See my photo gallery
My other project, CrypticWanderer.com

September 2010
Mon Tue Wed Thu Fri Sat Sun
<< <     
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30      

Countdown to 2008

Search

Categories

Archives

Linkblog

Places I visit

Other Blogs

Site Related Links

Weather at my place

Google Search

Google

Misc

Syndicate this blog XML

What is RSS?

Who's Online?

Guest Users: 1

powered by
b2evolution