Thanks, morrow
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class unit2project
{
static void Main(string[] args)
{
string entry, name, gender;
double weight, height, age, bmi, bmr, calrCalc;
char genderOpt, levelOpt, hcOpt;
// write opening Menu
Console.Write(" Health Calculators ");
Console.Write("\nOption 1: BMI (Body Mass Index)");
Console.Write("\nOption 2: BMR (Basal Metabolic Rate)/ Calorie Needs)");
Console.Write("\nOption 3: EXIT");
Console.Write("\nPlease type 1 for Option 1, 2 for Option 2, 3 for Option 3");
Console.Write("\nEnter one of the above option numbers: ");
hcOpt = Convert.ToChar(Console.ReadLine());
switch (Char.ToUpper(hcOpt))
{
case '1': //if opt(ion) 1, do BMI Calculation
Console.Write(" BMI Testing ");
Console.Write("\nBMI can be used to indicate if you are Underweight, Normal, Overweight, Obese");
Console.Write("\nEnter Weight: ");
weight = Convert.ToInt32(Console.ReadLine());
Console.Write("(12 inches in 1 foot");
Console.Write("Enter Height(inches please): ");
height = Convert.ToInt32(Console.ReadLine());
//BMI Formula
bmi = ((weight * 703) / (height * height));
Console.WriteLine("BMI = {0}", bmi);
if (bmi < 18.5) //BMI less than 18.5 = underweight
{
Console.WriteLine("According to my calculations you are Underweight");
}
if ((bmi == 18.5) || (bmi <= 24.9)); //BMI 18.5 to 24.9 = normal
{
Console.WriteLine("According to my calculations you are Normal");
}
if ((bmi == 25) || (bmi <= 29.9)) ; //BMI 25 to 29.9 = overweight
{
Console.WriteLine("According to calculations you are Overweight");
}
if (bmi >= 30) ; //BMI = 30 or above = obese
{
Console.WriteLine("According to calculations you are Obese");
}
break;
case '3':
Console.Clear();
break;
case '2':
Console.Write(" BMR/Calorie Needs Testing ");
Console.Write("\nBMR stands for Basal Metabolic Rate, once you know you BMR, you can calculate your Daily Calorie Needs");
Console.Write("\nEnter Weight: ");
weight = Convert.ToInt32(Console.ReadLine());
Console.Write(" (12 inches in 1 foot)");
Console.Write("Please Enter Height in Inches: ");
height = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter Age: ");
age = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter Gender: ");
Console.Write("Please Type M for male and F for female");
genderOpt = Convert.ToChar(Console.ReadLine());
switch (Char.ToUpper(genderOpt))
{
case 'F':
bmr = 665 + (4.35 * weight) + (4.7 * height) - (4.7 * age);
break;
case 'M':
bmr = 66 + (6.23 * weight) + (12.7 * height) - (6.8 * age);
break;
}
Console.Write("Please type one of the following rates of exercising: ");
levelOpt = Convert.ToChar(Console.ReadLine());
Console.Write("Please type 1 for little or no exercise");
Console.Write("Please type 2 for light exercise/sports 1-3 days per week");
Console.Write("Please type 3 for moderate exercise/sports 3 to 5 days per week");
Console.Write("Please type 4 for hard exercise/ sports 6 to 7 days per week");
Console.Write("Please type 5 for very hard exercise/sports & physical job or 2x training");
switch (Char.ToUpper(genderOpt))
{
case '1':
calrCalc = bmr * 1.2;
break;
case '2':
calrCalc = bmr * 1.375;
break;
case '3':
calrCalc = bmr * 1.55;
break;
case '4':
calrCalc = bmr * 1.725;
break;
case '5':
calrCalc = bmr * 1.9;
break;
}
Console.WriteLine("Your BMR is {0} and you total daily calorie needs are {1}.", bmr, calrCalc);
break;
}
Console.ReadLine();
}
}
I am getting the error at the end of my coding
switch (Char.ToUpper(genderOpt))
{
case '1':
calrCalc = bmr * 1.2; //error on bmr
break;
case '2':
calrCalc = bmr * 1.375;
break;
case '3':
calrCalc = bmr * 1.55;
break;
case '4':
calrCalc = bmr * 1.725;
break;
case '5':
calrCalc = bmr * 1.9;
break;
}
Console.WriteLine("Your BMR is {0} and you total daily calorie needs are {1}.", bmr, calrCalc); //error-calrCalc
break;
?? i have it labeled above
This post has been edited by Martyr2: 18 December 2010 - 11:47 PM
Reason for edit:: Please use code tags in the future, thanks!

New Topic/Question
Reply




MultiQuote




|