• Post Reply Bookmark Topic Watch Topic
  • New Topic

best approach for a small percent body fat web application  RSS feed

 
michael lenasalon
Greenhorn
Posts: 11
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to create a %body fat application probably in java,, i will use JSF as my MVC framwork.

i  have already coded the simple part for asking the user his waist circumference and wrist circumference.
the i get the difference as the "result"
I will then then pick the result and look up in a table (as attached) where the top row is the 'result' from my previous working
then the left COLUMN of my table (see the excel snip attached) is for the body weight,,,
the user will input the body weight and i will the cross check where the body weight and the 'result' cross check in the table is the '% body fat'

which is the best approach for this proble. i was figuring out working with arrays , hashmaps, databales or hardcoding the values in a java class and use 'if else'
but the data is large.
java-problem.PNG
[Thumbnail for java-problem.PNG]
this is part of the look up table, so if the result==25.5 (but it is 15 from the calculation below )inches and weight is 140kgs then output 15% body fat
find-in-look-up-table.PNG
[Thumbnail for find-in-look-up-table.PNG]
so the difference here is 15 but it can also be 25.5 as above. so pick this and check in the lookup tables top row and get weight then cross check
 
Campbell Ritchie
Sheriff
Posts: 54510
150
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch
You should get the app working with no GUI before you even think of drawing a GUI. I would suggest you have a FatPercentage object; you can enter weight and the two sizes in the constructors. Print out those details, then you will have to work out how to find the percentage. Do you really need a lookup table?
 
michael lenasalon
Greenhorn
Posts: 11
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Welcome to the Ranch
You should get the app working with no GUI before you even think of drawing a GUI. I would suggest you have a FatPercentage object; you can enter weight and the two sizes in the constructors. Print out those details, then you will have to work out how to find the percentage. Do you really need a lookup table?


thank you for checking on my problem. i know i wont need a GUI for now , i have already put the parameters in the construcotrs in a jsf managed bean,,, apart from weight which i can easily do.
the question how will i do the final part. take the result and the weight then output a cross matching %body fat value.... there is no automatic formulae as it is a research data!
 
Campbell Ritchie
Sheriff
Posts: 54510
150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please explain the structure of your lookup table; we cannot help until we know that.
 
michael lenasalon
Greenhorn
Posts: 11
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Please explain the structure of your lookup table; we cannot help until we know that.


from the snip above if my waist and wrist circumference difference is 25.5. and my weight is 140 pounds
then my body fat is 15% just like that
 
Campbell Ritchie
Sheriff
Posts: 54510
150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, I meant how is the table implemented.
 
michael lenasalon
Greenhorn
Posts: 11
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:No, I meant how is the table implemented.

kindly elaborate what you mean by implemented?
that is just an excel data, it is research data and no formula used to generate the body fat values.
so i was asking for certain algorithms or approach
e.g.
if (result==22.5&&weight==140){
return "140"
}else if{
......
}
and so on
the problem is my data is huge : 40 rows by 40 columns excel data.
unless am not getting you well.
 
Campbell Ritchie
Sheriff
Posts: 54510
150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, that is a really bad solution. You should consider what sort of data structure you might want to keep the percentages in.
On a different note, how did you validate those percentages?
 
Salil Wadnerkar
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to look up answers based on two values. It looks like you just want fastest lookups. So, you can use HashMap. In a Map, you can lookup values based on a key. Here, your key is a pair of waist and wrist circumference. You can create a class containing these two values (because in Java, there is no "pair" class) and appropriately overrride hashCode and equals methods - because HashMap uses them for the lookup.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!