Weight loss Programme

Joined
Oct 16, 2015
Messages
1
Reaction score
0
Hi,

the code works it calculates correctly but does no display the total pounds rounder to the nearest pound for example enter 60,60,60 and it should come out to .28 totalpounds lost but it comes to 27 see below for code.

namespace HNDApp1 {

classWeightLoss {

staticvoid Main(string[] args) {



constint cyclingCalories = 200;

constint caloriesForPoundLoss = 3500;

constint runningcalories = 475;

constint swimmingcalories = 275;



Console.Write("Enter number of minutes cycling: ");

int cyclingTime = int.Parse(Console.ReadLine());

int cyclingHours = cyclingTime / 60;

int cyclingMins = cyclingTime % 60;

double cyclingBurnt = Convert.ToDouble(cyclingTime / 60 * cyclingCalories);

double cyclingPounds = cyclingBurnt / caloriesForPoundLoss;

Console.Write("Enter number of minutes running: ");

int runningtime = int.Parse(Console.ReadLine());

int runninghours = runningtime / 60;

int runningmins = runningtime % 60;

double runningburnt = Convert.ToDouble(runningtime / 60 * runningcalories);

double runningpounds = runningburnt / caloriesForPoundLoss;

Console.Write("Enter number of minutes swimming: ");

int swimmingtime = int.Parse(Console.ReadLine());

int swimminghours = swimmingtime / 60;

int swimmingmins = swimmingtime % 60;

double swimmingburnt = Convert.ToDouble(swimmingtime / 60 * swimmingcalories);

double swimmingpounds = swimmingburnt / caloriesForPoundLoss;

Console.WriteLine("\n{0, -12}{1, -15}{2, -18}{3, -25}\n",

"Activity", "Time spent", "Calories burnt", "Pounds lost");

Console.WriteLine("{0, -15}{1, 5}:" + string.Format("{0:00}", cyclingMins) + "{3, 19:N2}{4, 15:N2}",

"Cycling", cyclingHours, cyclingMins, cyclingBurnt, cyclingPounds);

Console.WriteLine("{0, -15}{1, 5}:" + string.Format("{0:00}", runningmins) + "{3, 19:N2}{4, 15:N2}",

"running", runninghours, runningmins, runningburnt, runningpounds);

Console.WriteLine("{0, -15}{1, 5}:" + string.Format("{0:00}", swimmingmins) + "{3, 19:N2}{4, 15:N2}",

"swimming", swimminghours, swimmingmins, swimmingburnt, swimmingpounds);

float totalhours = swimminghours + runninghours + cyclingHours;

float totalmins = swimmingmins + runningmins + cyclingMins;

double totalburnt = swimmingburnt + runningburnt + cyclingBurnt;

double totalpounds = swimmingpounds + runningpounds + cyclingPounds;


Console.WriteLine("\n{0, -15}{1, 5}:{2}{3, 19:N2}{4, 15:N2}" ,

"Total", totalhours, totalmins, totalburnt, totalpounds);





Console.ReadLine();

}

}

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,057
Messages
2,570,443
Members
47,113
Latest member
XZJMike318

Latest Threads

Top