Home > Articles > Programming > Java

  • Print
  • + Share This
This chapter is from the book

Making a Difference

2.33

(Body Mass Index Calculator) We introduced the body mass index (BMI) calculator in Exercise 1.10. The formulas for calculating BMI are

069equ01.jpg

or

069equ02.jpg

Create a BMI calculator that reads the user's weight in pounds and height in inches (or, if you prefer, the user's weight in kilograms and height in meters), then calculates and displays the user's body mass index. Also, display the following information from the Department of Health and Human Services/National Institutes of Health so the user can evaluate his/her BMI:

BMI VALUES
Underweight: less than 18.5
Normal:      between 18.5 and 24.9
Overweight:  between 25 and 29.9
Obese:       30 or greater

[Note: In this chapter, you learned to use the int type to represent whole numbers. The BMI calculations when done with int values will both produce whole-number results. In Chapter 3 you'll learn to use the double type to represent numbers with decimal points. When the BMI calculations are performed with doubles, they'll both produce numbers with decimal points—these are called "floating-point" numbers.]

2.34

(World Population Growth Calculator) Use the web to determine the current world population and the annual world population growth rate. Write an application that inputs these values, then displays the estimated world population after one, two, three, four and five years.

2.35

(Car-Pool Savings Calculator) Research several car-pooling websites. Create an application that calculates your daily driving cost, so that you can estimate how much money could be saved by car pooling, which also has other advantages such as reducing carbon emissions and reducing traffic congestion. The application should input the following information and display the user's cost per day of driving to work:

  1. Total miles driven per day.
  2. Cost per gallon of gasoline.
  3. Average miles per gallon.
  4. Parking fees per day.
  5. Tolls per day.
  • + Share This
  • 🔖 Save To Your Account