Body mass index is a measure of whether someone’s weight is appropriate for their height. A body-mass-index value between 19 and 25 is considered to be in the normal range. Here’s the formula for calculating body mass index:

bmi = 704 x weightInPounds / heightInInches2

Implement a program that prompts the user for height and weight values and displays the associated body mass index.

Perform input validation by making sure that the user enters a positive integer number for feet, a nonnegative decimal number for inches, and a positive decimal number for weight. See the sample session for details. In particular, note the format for the echo-printed height and weight values and for the generated body-mass-index value.

A sample run of the program is shown below. (Note: Bold texts are user input.)

Welcome to the body mass calculator!

Enter height using feet space inches (e.g., 5 6.25): hi there

Invalid feet value. Must be an integer.

Invalid inches value. Must be a decimal number.

Re-enter height using feet space inches (e.g., 5 6.25): 0 9

Invalid feet value. Must be positive.

Re-enter height using feet space inches (e.g., 5 6.25): 5.25 0

Invalid feet value. Must be an integer.

Re-enter height using feet space inches (e.g., 5 6.25): 5 9.25

Enter weight in pounds: 0

Invalid pounds value. Must be positive.

Re-enter weight in pounds: 150.5

height = 5'-9.25"

weight = 150.5 pounds

body mass index = 22.1

Thank you, good bye!

Many companies use telephone numbers like 555-GET-FOOD so the number is easier for their customers to remember. On a standard telephone, the alphabetic letters are mapped to number in the following fashion:

A, B, and C = 2

D, E, and F = 3

G, H, and I = 4

J, K, and L = 5

M, N, and O = 6

P, Q, R, and S = 7

T, U, and V = 8

W, X, Y, and Z = 9

Write an application that asks the user to enter a 10-character telephone number (in any format such as: XXXXXXXXXX, (XXX) XXX-XXXX, or XXX-XXX-XXXX). The application should display the telephone number with any alphabetic characters that appear in the original translated appropriately to their numeric equivalent. For example, if the user enters 555-GETFOOD the application should display 555-438-3663.

Academic Honesty!

It is not our intention to break the school's academic policy. Projects posted are only used as a reference
and should not be submitted as is. We are not held liable for any misuse of the solutions.
Please see the frequently asked questions page
for further questions and inquiries.