Programming Drill #3

Due: Thursday, May 22
Goal: Use an IDE (NetBeans) and work with keyboard input

Re-do the twix bar calculator that we covered in class, except this time allow the user to input their age (in years), weight (in pounds), and height (in feet and then in additional inches) then have the program display how many twix the person can eat to maintain their weight.  You must write your solution using NetBeans!

For your reference, the example is repeated below.  You can pick either the male or female formula.

To maintain one's body weight, a human that is A years old, weighs K kilograms and is H centimers tall needs to consume approximately the following number of Calories per day:

 

Males:       10*K + 6.25*H - 5*A + 5

Females:    10*K + 6.25*H - 5*A - 161

 

(One Calorie is also referred to as one kilo-calorie or kcal.  A kilocalorie is what food manufacturers refer to as a single "Calorie" on food labels.)   This formula is derived from the Mifflin-St Jeor equations and is an approximation based on a person that engages in no physical activity - i.e. the person basically stays in bed all day.

 

One package of twix (i.e. two cookie bars, because nobody eats just one) is 568 Calories according to the M&M/Mars website.  If you go on the twix-only diet all day long, then the number of twix bars you would need to eat is TotalCaloriesNeeded / 568.

 

Write a program that has variables for:

Choose appropriate data types for the variables.  Set these variables to whatever values you like (or use your own).  Make additional variables for:

From these values you can use the Mifflin-St Jeor equation to compute how many twix bars that person should eat to maintain their body weight.  Make a form with a button that when clicked outputs the number.

Feel free to substitute calories for other foods if you like, for example, Hardee's "Monster Thickburger" is 1420 Calories.  See http://www.calorie-count.com/ for calorie counts for common foods.