CCC '08 J1 - Body Mass Index

View as PDF

Submit solution

Points: 3
Time limit: 2.0s
Memory limit: 64M

Problem type

The Body Mass Index (BMI) is one of the calculations used by doctors to assess an adult's health. The doctor measures the patient's height (in metres) and weight (in kilograms), then calculates the BMI using the formula:

\displaystyle  BMI = \frac{weight}{height \times height}

Write a program which takes the patient's weight and height as input, calculates the BMI, and displays the corresponding message from the table below.

BMI Category Message
More than 25 Overweight
Between 18.5 and 25.0 (inclusive) Normal weight
Less than 18.5 Underweight

Sample Input 1

69
1.73

Output for Sample Input 1

Normal weight

Explanation for Output in Sample Input 1

The BMI is \frac{69}{1.73 \times 1.73} which is approximately 23.0545. According to the table, this is a "Normal weight".

Sample Input 2

84.5
1.8

Output for Sample Input 2

Overweight

Explanation for Output in Sample Input 2

The BMI is \frac{84.5}{1.8 \times 1.8}, which is approximately 26.0802. According to the table, this is "Overweight".


Comments


  • -2
    ericzhou9  commented on Feb. 9, 2019, 10:46 a.m.

    me too it always say INput mismatch


  • -3
    retronerd2016  commented on Oct. 28, 2017, 8:31 p.m.

    how do you make it so that it doesn't tell you INput misMatch all the time, I try to insert a decimal in the console and it can't show up.


  • 5
    Mr_Lim  commented on Oct. 24, 2017, 12:24 p.m.

    "Write a program which prompts for the patient's height and weight" should be changed. No prompting should be done, and the input order is weight first, then height.


    • 0
      Phoenix1369  commented on Oct. 26, 2017, 4:20 p.m.

      Fixed, thanks!


  • -7
    mozart  commented on Oct. 1, 2017, 9:53 a.m.

    This comment is hidden due to too much negative feedback. Click here to view it.