모든 챌린지
쉬움 0명 해결 정답률 0%

Body Mass Index

Compute BMI from weight and height.

문제

Body mass index (BMI) is weight in kilograms divided by the square of height in meters.

Implement body_mass_index(weight_kg, height_m).

Input

weight_kg: Weight in kilograms. height_m: Height in meters.

Output

Return weight_kg / (height_m × height_m).

제약 조건

1 ≤ weight_kg ≤ 500; 0.5 ≤ height_m ≤ 2.5

예시

예시 1
입력:
height_m = 1.8
weight_kg = 72.0

예상 출력:
expected = 22.222222
입력:
double height_m = 1.8;
double weight_kg = 72.0;

예상 출력:
double expected = 22.222222;
입력:
double height_m = 1.8;
double weight_kg = 72.0;

예상 출력:
double expected = 22.222222;

설명

1.8 × 1.8 = 3.24 and 72 / 3.24 ≈ 22.2222.

예시 2
입력:
height_m = 1.0
weight_kg = 50.0

예상 출력:
expected = 50.0
입력:
double height_m = 1.0;
double weight_kg = 50.0;

예상 출력:
double expected = 50.0;
입력:
double height_m = 1.0;
double weight_kg = 50.0;

예상 출력:
double expected = 50.0;

설명

With a height of 1 meter the BMI equals the weight: 50.

참고 자료

이 문제는 CodeUtility에 맞게 수정되었습니다. 위의 설명과 제한 조건을 따르세요.

다른 사람의 풀이 보기

커뮤니티 솔루션

아직 공개된 풀이가 없습니다. 문제를 풀고 첫 풀이를 공유하세요.