Advertisement
AlexTasev

CalorieCalculator

Apr 28th, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.37 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _2_CalorieCalculator  
  4. {
  5.     class Program
  6.     {
  7.         static void Main()
  8.         {
  9.             char gender = char.Parse(Console.ReadLine());
  10.             double weightKg = double.Parse(Console.ReadLine());
  11.             double heightM = double.Parse(Console.ReadLine());
  12.             int age = int.Parse(Console.ReadLine());
  13.             string phisicalActivity = Console.ReadLine();
  14.  
  15.             double calories = 0;
  16.  
  17.             if (gender == 'm')
  18.             {
  19.                 calories = 66 + (13.7 * weightKg) + (5 * heightM * 100) - (6.8 * age);
  20.             }
  21.             else if (gender == 'f')
  22.             {
  23.                 calories = 655 + (9.6 * weightKg) + (1.8 * heightM * 100) - (4.7 * age);
  24.             }
  25.  
  26.             switch (phisicalActivity)
  27.             {
  28.                 case "sedentary":
  29.                     calories *= 1.2;
  30.                     break;
  31.                 case "lightly active":
  32.                     calories *= 1.375;
  33.                     break;
  34.                 case "moderately active":
  35.                     calories *= 1.55;
  36.                     break;
  37.                 case "very active":
  38.                     calories *= 1.725;
  39.                     break;
  40.             }
  41.  
  42.             Console.WriteLine($"To maintain your current weight you will need {Math.Ceiling(calories)} calories per day.");
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement