# Won't calculate after I ask to enter exercise amount?!?

Page 1 of 1

## 4 Replies - 542 Views - Last Post: 24 September 2012 - 05:58 AMRate Topic: 1 Votes //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=292943&amp;s=0bd5e5ce7a07d021df8e1f3b229ed6fe&md5check=' + ipb.vars['secure_hash'], cur_rating: 3, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 mshumann

Reputation: 1
• Posts: 2
• Joined: 23-September 12

# Won't calculate after I ask to enter exercise amount?!?

Posted 23 September 2012 - 01:36 PM

```using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
double weight = 0;
double height = 0;
double years = 0;
double sex = 0;
double BMR = 0;
double exercise = 0;
double calories = 0;
double meal = 0;
Console.WriteLine("Welcome to Matt's Calorie Counter!");
Console.WriteLine("Let's get started!!! First we have to calculate your BMR.");
Console.WriteLine("Tell me your weight in pounds: ");
Console.WriteLine("Tell me your height in inches: ");
Console.WriteLine("Tell me your age in years (I won't tell a soul): ");
Console.WriteLine("What sex are you? Enter 1 for Male or 2 for Female: ");
if (sex == 1)
{
Console.WriteLine("Your BMR is  " + (66 + (6.23 * weight) + (12.7 * height) - (6.8 * years)));
}
else
{
Console.WriteLine("Your BMR is " + (655 + (4.35 * weight) + 4.7 * (height) - (4.7 * years)));
}

Console.WriteLine("1. You don't exercise.\n2. You engage in light exercise 1-3 days a week.\n3. You exercise moderately 3-5 times a week.\n4. You exercise intensely 6-7 days a week.\n5. You exercise intensely 7 days a week and have a physically active job.\n");
do
if (exercise == 1)
{

Console.WriteLine(" To maintain your weight your maximum calorie intake should be:" + (BMR * 1.357));
calories = (BMR * 1.357);
}
else if (exercise == 2)
{

Console.WriteLine(" To maintain your weight your maximum calorie intake should be: {0}", calories = (BMR * 1.55));
calories = (BMR * 1.55);
}

else if (exercise == 3)
{

Console.WriteLine(" To maintain your weight your maximum calorie intake should be: {0}", calories = (BMR * 1.357));
calories = (BMR * 1.357);
}
else if (exercise == 4)
{

Console.WriteLine(" To maintain your weight your maximum calorie intake should be: {0}", calories = (BMR * 1.725));
calories = (BMR * 1.725);
}
else
{

Console.WriteLine(" To maintain your weight your maximum calorie intake should be: {0}", calories = (BMR * 1.9));
calories = (BMR * 1.9);
}

Console.WriteLine("your calories lefts for the day are :", calories);
Console.WriteLine(" Would you like to enter a caloric value for a meal or snack? Enter 1 for yes and 2 for no");
```

MOD EDIT: Added code tags. When posting code...USE CODE TAGS!!!

This post has been edited by JackOfAllTrades: 23 September 2012 - 02:21 PM

Is This A Good Question/Topic? 0

## Replies To: Won't calculate after I ask to enter exercise amount?!?

### #2 mshumann

Reputation: 1
• Posts: 2
• Joined: 23-September 12

## Re: Won't calculate after I ask to enter exercise amount?!?

Posted 23 September 2012 - 01:43 PM

The "do" before the else if statement is not supposed to be there.I was trying something else and did not delete all the way.

### #3 November-06

• D.I.C Regular

Reputation: 48
• Posts: 452
• Joined: 04-January 11

## Re: Won't calculate after I ask to enter exercise amount?!?

Posted 24 September 2012 - 02:53 AM

Try using .ToString() to non-string variables and equations when displaying.

```Console.WriteLine("your calories left for the day are :", calories.ToString());

```

Also, try to change this line

```Console.WriteLine(" To maintain your weight your maximum calorie intake should be: {0}", calories = (BMR * 1.357));

```

to

```Console.WriteLine(" To maintain your weight your maximum calorie intake should be: {0}", (BMR * 1.357).ToString());

```

Try to do the same to lines similar to this.

### #4 rgfirefly24

• D.I.C Lover

Reputation: 410
• Posts: 2,043
• Joined: 07-April 08

## Re: Won't calculate after I ask to enter exercise amount?!?

Posted 24 September 2012 - 05:44 AM

you are attempting to set a variable within all of your calls to Console.WriteLine. Remove all of the instances of calories = from your Console.WriteLine calls.

EX:
```Console.WriteLine(" To maintain your weight your maximum calorie intake should be: {0}", calories = (BMR * 1.357));

```

should be

```Console.WriteLine(" To maintain your weight your maximum calorie intake should be: {0}", (BMR * 1.357));

```

This post has been edited by rgfirefly24: 24 September 2012 - 06:08 AM

### #5 Curtis Rutland

• （╯°□°）╯︵ (~ .o.)~

Reputation: 4990
• Posts: 9,010
• Joined: 08-June 10

## Re: Won't calculate after I ask to enter exercise amount?!?

Posted 24 September 2012 - 05:58 AM

@November-06, there's no real need to add ToString method calls in a Console.WriteLine call. Parameters will automatically have their ToString methods called, because Console.Out is a TextWriter.