Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace BodyMassIndex
- {
- using System;
- public class BodyMassIndex
- {
- public static void Main(string[] args)
- {
- checked
- {
- int count = int.Parse(Console.ReadLine());
- double[,] measures = new double[count, 2];
- for (int row = 0; row < count; row++)
- {
- string inputLine = Console.ReadLine();
- char[] separators = new char[] { ' ', ',', ';' };
- string[] numStr = inputLine.Split(separators, StringSplitOptions.RemoveEmptyEntries);
- for (int col = 0; col < 2; col++)
- {
- measures[row, col] = double.Parse(numStr[col]);
- }
- }
- for (int row = 0; row < measures.GetLength(0); row++)
- {
- double result = CalculateBodyMassIndexOfOnePerson(measures[row, 0], measures[row, 1]);
- PrintResultGrade(result);
- }
- }
- }
- private static void PrintResultGrade(double result)
- {
- checked
- {
- if (result < 18.5)
- {
- Console.Write("under ");
- }
- else if (result >= 18.5 && result < 25.0)
- {
- Console.Write("normal ");
- }
- else if (result >= 25.0 && result < 30.0)
- {
- Console.Write("over ");
- }
- else if (result >= 30.0)
- {
- Console.Write("obese ");
- }
- }
- }
- private static double CalculateBodyMassIndexOfOnePerson(double weight, double height)
- {
- checked
- {
- double bmi = weight / (height * height);
- return bmi;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement