Advertisement
braveheart1989

01.Daily_Calorie_Intake

Feb 8th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.12 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _01.Daily_Calorie_Intake
  8. {
  9.     class Daily_Calorie_Intake
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             //Women: BMR = 655 + (9.563 x weight in kg) +(1.850 x height in cm) – (4.676 x age in years)
  14.  
  15.             //1.    W – weight in pounds (lbs.)
  16.             decimal weightInPounds = decimal.Parse(Console.ReadLine());
  17.             //2.    H – height in inches
  18.             decimal heightInInches = decimal.Parse(Console.ReadLine());
  19.             //3.    A – age
  20.             decimal age = decimal.Parse(Console.ReadLine());
  21.             //4.    G – gender
  22.             string gender = Console.ReadLine().ToLower();
  23.             //5.    E – workouts per week
  24.             decimal workoutsPerWeek = decimal.Parse(Console.ReadLine());
  25.  
  26.             decimal weightInkg = weightInPounds / 2.20M;
  27.             decimal heightInCm = heightInInches * 2.54M;
  28.  
  29.  
  30.             decimal bmrMen = 0.0M;
  31.             decimal bmrWomen = 0.0M;
  32.  
  33.             //No workouts DCI = BMR * 1.2
  34.             //1–3 workouts per week DCI = BMR * 1.375
  35.             //4–6 workouts per week DCI = BMR * 1.55
  36.             //7–9 workouts per week DCI = BMR * 1.725
  37.             //Extra heavy workouts DCI = BMR * 1.9
  38.  
  39.             decimal dci = 0.0M;
  40.  
  41.             switch (gender)
  42.             {
  43.                 //Men: BMR = 66.5 + (13.75 x weight in kg) + (5.003 x height in cm) – (6.755 x age in years)
  44.  
  45.                 case "m": bmrMen= 66.5M + (13.75M * weightInkg) + (5.003M * heightInCm) - (6.755M * age);
  46.  
  47.                     if (workoutsPerWeek == 0)
  48.                     {
  49.                         dci = Math.Floor(bmrMen * 1.2M);
  50.                         Console.WriteLine(dci);
  51.                     }
  52.                     else if (workoutsPerWeek >= 1M && workoutsPerWeek<= 3M)
  53.                     {
  54.                         dci = Math.Floor(bmrMen * 1.375M);
  55.                         Console.WriteLine(dci);
  56.                     }
  57.                     else if (workoutsPerWeek >= 4M && workoutsPerWeek<= 6M)
  58.                     {
  59.                         dci = Math.Floor(bmrMen * 1.55M);
  60.                         Console.WriteLine(dci);
  61.                     }
  62.                     else if (workoutsPerWeek >= 7M && workoutsPerWeek <= 9M)
  63.                     {
  64.                         dci = Math.Floor(bmrMen * 1.725M);
  65.                         Console.WriteLine(dci);
  66.                     }
  67.                     else
  68.                     {
  69.                         dci = Math.Floor(bmrMen * 1.9M);
  70.                         Console.WriteLine(dci);
  71.                     }
  72.                     break;
  73.  
  74.                 //Women: BMR = 655 + (9.563 x weight in kg) + (1.850 x height in cm) – (4.676 x age in years)
  75.  
  76.                 case "f":
  77.                     bmrWomen = 655M + (9.563M * weightInkg) + (1.850M * heightInCm) - (4.676M * age);
  78.  
  79.                     if (workoutsPerWeek == 0M)
  80.                     {
  81.                         dci = Math.Floor(bmrWomen * 1.2M);
  82.                         Console.WriteLine(dci);
  83.                     }
  84.                     else if (workoutsPerWeek >= 1M && workoutsPerWeek <= 3M)
  85.                     {
  86.                         dci = Math.Floor(bmrWomen * 1.375M);
  87.                         Console.WriteLine(dci);
  88.                     }
  89.                     else if (workoutsPerWeek >= 4M && workoutsPerWeek <= 6M)
  90.                     {
  91.                         dci = Math.Floor(bmrWomen * 1.55M);
  92.                         Console.WriteLine(dci);
  93.                     }
  94.                     else if (workoutsPerWeek >= 7M && workoutsPerWeek <= 9M)
  95.                     {
  96.                         dci = Math.Floor(bmrWomen * 1.725M);
  97.                         Console.WriteLine(dci);
  98.                     }
  99.                     else
  100.                     {
  101.                         dci = Math.Floor(bmrWomen * 1.9M);
  102.                         Console.WriteLine(dci);
  103.                     }
  104.                     break;
  105.                 default:
  106.                     break;
  107.             }
  108.         }
  109.     }
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement