본문 바로가기

Baekjoon/C++

[C++][BOJ/백준] 6825 Body Mass Index

 

 

Baekjoon Online Judge

 

6825번: Body Mass Index

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 BMI = weight/(height × height).

www.acmicpc.net

 

 

[문제]

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

BMI = weight/(height × height).

Write a program which prompts for the patient’s height and weight, calculates the BMI, and displays the corresponding message from the table below.

 

 


 

[코드]

#include <iostream>
#include <cmath>
using namespace std;

int main()
{
    double w, h;

    cin >> w >> h;

    if (w / pow(h, 2) > 25)
        cout << "Overweight" << '\n';
    else if (w / pow(h, 2) > 18.5)
        cout << "Normal weight" << '\n';
    else
        cout << "Underweight" << '\n';

    return 0;
}