Advertisement
Spocoman

Calorie Calculator

Sep 23rd, 2023
826
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.48 KB | None | 0 0
  1. using System;
  2.  
  3. namespace CalorieCalculator
  4. {
  5.     internal class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             char gender = char.Parse(Console.ReadLine());
  10.             double weight = double.Parse(Console.ReadLine());
  11.             double height = double.Parse(Console.ReadLine());
  12.             int age = int.Parse(Console.ReadLine());
  13.             string physicalActivity = Console.ReadLine();
  14.  
  15.             double basalMetabolicRate;
  16.             double coefficientActivity;
  17.  
  18.             if (gender == 'm')
  19.             {
  20.                 basalMetabolicRate = 66 + weight * 13.7 + height * 500 - 6.8 * age;
  21.             }
  22.             else
  23.             {
  24.                 basalMetabolicRate = 655 + weight * 9.6 + height * 180 - 4.7 * age;
  25.             }
  26.  
  27.             if (physicalActivity == "sedentary")
  28.             {
  29.                 coefficientActivity = 1.2;
  30.             }
  31.             else if (physicalActivity == "lightly active")
  32.             {
  33.                 coefficientActivity = 1.375;
  34.             }
  35.             else if (physicalActivity == "moderately active")
  36.             {
  37.                 coefficientActivity = 1.55;
  38.             }
  39.             else
  40.             {
  41.                 coefficientActivity = 1.725;
  42.             }
  43.  
  44.             double calories = basalMetabolicRate * coefficientActivity;
  45.  
  46.             Console.WriteLine($"To maintain your current weight you will need {Math.Ceiling(calories)} calories per day.");
  47.         }
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement