Weight loss Programme

Discussion in 'C Programming' started by Pewpewyou, Oct 16, 2015.

  1. Pewpewyou

    Pewpewyou

    Joined:
    Oct 16, 2015
    Messages:
    1
    Likes Received:
    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();

    }

    }

    }
     
    Pewpewyou, Oct 16, 2015
    #1
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.
Similar Threads
  1. moondaddy
    Replies:
    4
    Views:
    1,004
    S. Justin Gengo
    Jun 29, 2004
  2. =?Utf-8?B?cm9kY2hhcg==?=

    esitmate for dataset weight

    =?Utf-8?B?cm9kY2hhcg==?=, Sep 16, 2005, in forum: ASP .Net
    Replies:
    5
    Views:
    611
    Robbe Morris [C# MVP]
    Sep 17, 2005
  3. Song Ching Koh
    Replies:
    2
    Views:
    10,356
    Nils O. =?iso-8859-1?Q?Sel=E5sdal?=
    Oct 31, 2003
  4. j
    Replies:
    2
    Views:
    539
    James Birchfield
    Nov 26, 2003
  5. Minti
    Replies:
    4
    Views:
    1,181
    John C. Bollinger
    Feb 12, 2004
  6. udhayakumar

    About Heavy Weight Component

    udhayakumar, Sep 29, 2004, in forum: Java
    Replies:
    10
    Views:
    7,353
    Andrew Thompson
    Oct 6, 2004
  7. Sally Thompson

    Weight of horizontal rule

    Sally Thompson, Nov 6, 2003, in forum: HTML
    Replies:
    34
    Views:
    6,776
    Mark Parnell
    Nov 11, 2003
  8. Madame Blablavatsky

    'font-weight' problem

    Madame Blablavatsky, Jul 26, 2005, in forum: HTML
    Replies:
    6
    Views:
    695
    Jukka K. Korpela
    Aug 2, 2005
Loading...