Question: why when user input minutes under 59 it always returns as calorie burnt is 0 and the formula never works. what is input formula not
why when user input minutes under 59 it always returns as calorie burnt is 0 and the formula never works. what is input formula not correct?
Please take a look at the C# in .Net code as follows:
namespace Calories { class Program { static void Main(string[] args) { int walkedminutes; double calorieburnt; double weightInKg = 68.0389; //150 pounds equals 68.0389 kg double kph = 6.43738; //4 miles per hour equals 6.43738 kilometer per hour double walkedhours; Console.Write("Enter how many minutes you spent for walking 4 miles: "); walkedminutes = int.Parse(Console.ReadLine()); if (walkedminutes != 0) { Console.Write("Minutes you walked for 4 miles is "); Console.WriteLine(walkedminutes); walkedhours = walkedminutes / 60; //convert minutes to hours double kphSquare = Math.Pow(kph, 2); double kphCube = Math.Pow(kph, 3); calorieburnt = (0.0215 * kphCube - 0.1765 * kphSquare + 0.8710 * kph + 1.4577) * weightInKg * walkedhours; //formula used for for calorieburnt=[0.0215 x KPH3 - 0.1765 x KPH2 + 0.8710 x KPH + 1.4577] x WeightinKg x TimeInHours if (walkedminutes > 59) { Console.Write("Calorie you burnt is "); Console.WriteLine(calorieburnt); calorieburnt = double.Parse(Console.ReadLine()); Console.WriteLine(" Great job"); } if (walkedminutes <= 59) { Console.Write("Calorie you burnt is "); Console.WriteLine(calorieburnt); Console.WriteLine(" Calculator could not find your fast walk burnt calorie"); Console.WriteLine(" You should walk to burn your calories"); } else { Console.WriteLine(" calculator coudnot find your fast walk burnt calorie"); } } else { Console.WriteLine(" You should walk to burn your calories"); } { Console.WriteLine(" press any key to quit."); Console.ReadKey(); } } } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
