Question

In: Computer Science

:  Create a new blank C# console application Your basal metabolic rate is the rate...

:  Create a new blank C# console application Your basal metabolic rate is the rate at which the body uses energy while at rest to keep vital functions going, such as breathing and keeping warm. This calculation is vital to weight management, as it allows you to determine calories needed to maintain, lose, or gain weight. To determine your BMR, use the appropriate formula: Female: 655+(4.35 x weight in pounds)+(4.7 x height in inches)-(4.7 x age in years) Males: 66+(6.23x weight in pounds)+(12.7 x height in inches)-(6.8 x age in years) Taken from:"Count Calories to Maintain Weight | LIVESTRONG.COM." Http://www.livestrong.com. Web. 6 June 2010. 

Write the simple code in Main that asks for and stores (in the appropriate data types) the following information input by the user: their name, age, weight, height and gender; you can assume/prompt that the weight should be in pounds and the height should be in inches. Go ahead and store gender in a string, for now.

 Based on the user input, calculate their BMR.  Display back to the user the information they entered plus the BMR that you calculated. For both parts, be sure to run and test your program to ensure it works as you intended. Test Data for part 2: Female, 63”, 120 lbs, age 32, BMR = 1322.7 Male, 72”, 200 lbs, age 32, BMR = 2008.8

Solutions

Expert Solution

using System;

namespace Lab5
{
   class MainClass
   {
       public static void Main (string[] args)
       {
           //declares variables - 10 Points
           string name;
           double height, weight;
           int userAge;
           string gender;
           double BMR = 0;
           double exerciseFactor;
           double allowedCalories = 0;

           //asks for and stores data appropriately - 20 points
           Console.Write("Enter your name: ");
           name = Console.ReadLine ();
           Console.Write("Enter your height in inches: ");
           height = Convert.ToDouble(Console.ReadLine ());
           Console.Write ("Enter your weight in pounds: ");
           weight = Convert.ToDouble(Console.ReadLine ());
           Console.Write ("Enter your age: ");
           userAge = Convert.ToInt32(Console.ReadLine ());
           Console.Write ("Enter your gender as M or F: ");
           gender = Console.ReadLine ();

           //Conditional calculation of BMR - 20 Points
           if(gender == "F")
           {
               BMR = 655+(4.35 * weight) + (4.7 * height) - (4.7 * userAge );
           }
           else if(gender == "M")
           {
               BMR = 66+(6.23 * weight) + (12.7 * height) - (6.8 * userAge);
           }
              
           Console.Write ("1 - You don't exercise. \n2 - You engage in light exercise one to three days a week." +
           "\n3 - You exercise moderately three to five times a week.\n4 - You exercise intensely six to seven days a week." +
           "\n5 - You exercise intensely six to seven days a week and have a physically active job.\n");

           Console.Write("What is your level of activity: ");

           exerciseFactor = Convert.ToDouble(Console.ReadLine());
           //when user chooses number, it calculates the allowed calories
           if (exerciseFactor == 1) {
               allowedCalories = BMR * 1.2;
           } else if (exerciseFactor == 2) {
               allowedCalories = BMR * 1.375;
           } else if (exerciseFactor == 3) {
               allowedCalories = BMR * 1.55;
           } else if (exerciseFactor == 4) {
               allowedCalories = BMR * 1.725;
           } else if (exerciseFactor == 5) {
               allowedCalories = BMR * 1.725;
           } else {
               Console.WriteLine ("You need to input a value between 1 - 5.");
           }
           Console.WriteLine ();

           //Appropriate output as required by the lab - 20 Points
           Console.WriteLine (name + " you entered: \nHeight: " + height + "\nWeight: " + weight + "\nAge: " + userAge + "\nGender: " + gender);
           Console.WriteLine ("Your BMR is " + BMR);
           Console.WriteLine ("The allowed calories you can have per day is " + allowedCalories);

           Console.WriteLine ();

           string response = "YES";
           //given in the lab
           while (response == "YES")
           {
               int caloriesNow;
               Console.Write ("Enter the amount of calories you just ate: ");
               caloriesNow = Convert.ToInt32 (Console.ReadLine ());
               allowedCalories = allowedCalories - caloriesNow;
               Console.WriteLine ("The amount of calories left to eat is " + allowedCalories);
               Console.Write ("Would you like to continue? ");
               response = Console.ReadLine ();
               response = response.ToUpper ();
               //this is an if statement to show that if allowed calories is below 0, it tells user you went below zero
               //but it also asks if they want to continue, because they can enter in more information.
               if (allowedCalories < 0) {
                   Console.WriteLine ("You have went passed the amount of calories. You are at " + allowedCalories + "calories.");
                   Console.Write ("Would you like to continue? ");
                   response = Console.ReadLine ();
                   response = response.ToUpper ();
               }
           }
           //displays the final allowed calories
           Console.WriteLine ();
           Console.WriteLine ("The amount of calories you have left is " + allowedCalories);
       }
   }
}


Related Solutions

Language: C# Create a new Console Application. Your Application should ask the user to enter their...
Language: C# Create a new Console Application. Your Application should ask the user to enter their name and their salary. Your application should calculate how much they have to pay in taxes each year and output each amount as well as their net salary (the amount they bring home after taxes are paid!). The only taxes that we will consider for this Application are Federal and FICA. Your Application needs to validate all numeric input that is entered to make...
C# Create a console application that prompts the user to enter a regular expression, and then...
C# Create a console application that prompts the user to enter a regular expression, and then prompts the user to enter some input and compare the two for a match until the user presses Esc: The default regular expression checks for at least one digit. Enter a regular expression (or press ENTER to use the default): ^[a- z]+$ Enter some input: apples apples matches ^[a-z]+$? True Press ESC to end or any key to try again. Enter a regular expression...
C# & ASP.NET Create a console application that prompts the user to enter a regular expression,...
C# & ASP.NET Create a console application that prompts the user to enter a regular expression, and then prompts the user to enter some input and compare the two for a match until the user presses Esc: The default regular expression checks for at least one digit. Enter a regular expression (or press ENTER to use the default): ^[a- z]+$ Enter some input: apples apples matches ^[a-z]+$? True Press ESC to end or any key to try again. Enter a...
C# Create a console application named that creates a list of shapes, uses serialization to save...
C# Create a console application named that creates a list of shapes, uses serialization to save it to the filesystem using XML, and then deserializes it back: // create a list of Shapes to serialize var listOfShapes = new List<Shape> { new Circle { Colour = "Red", Radius = 2.5 }, new Rectangle { Colour = "Blue", Height = 20.0, Width = 10.0 }, new Circle { Colour = "Green", Radius = 8 }, new Circle { Colour = "Purple",...
Define basal metabolism and explain the factors that affect basal metabolic rate. What body mass index...
Define basal metabolism and explain the factors that affect basal metabolic rate. What body mass index (BMI) values are associated with being underweight, normal, overweight and obese? Name the factors that affect body fat composition and distribution. What are components of a sound approach to weight management? Choose a popular weight-loss diet; list and explain the pros and cons with citations/credible sources for each.
Calculated DRI: 3570 Your Basal Metabolic Rate is: 2136 calories. Your Average Daily Calorie Need Is:...
Calculated DRI: 3570 Your Basal Metabolic Rate is: 2136 calories. Your Average Daily Calorie Need Is: 2563 calories Explain why in order to lose weight you would need to ingest fewer Calories per day, or expend enough energy per day, so the net ingested daily Calories are less than the calculated DRI. How long would it theoretically take to lose the equivalent of one pound of fat if you ingested 100 calories/day less than the DRI? Would you agree that...
Create a C# Windows Console application that displays the following patterns separately, one after the other....
Create a C# Windows Console application that displays the following patterns separately, one after the other. You MUST use nested for loops to generate the patterns. All asterisks (*) should be displayed by a single statement of the form Console.Write("*"); which causes the asterisks to display side by side. A statement of the form Console.WriteLine(); can be used to move to the next line. A statement of the form Console.Write(" "); can be used to display a space for the...
Create a simple C++ application that will exhibit concurrencyconcepts. Your application should create two threads...
Create a simple C++ application that will exhibit concurrency concepts. Your application should create two threads that will act as counters. One thread should count up to 20. Once thread one reaches 20, then a second thread should be used to count down to 0. For your created code, provide a detailed analysis of appropriate concepts that could impact your application. Specifically, address:Performance issues with concurrencyVulnerabilities exhibited with use of stringsSecurity of the data types exhibited.
25-1/Which hormone increases basal metabolic rate? Select one: _ a. Cortisol b. Insulin c. Thyroxine d....
25-1/Which hormone increases basal metabolic rate? Select one: _ a. Cortisol b. Insulin c. Thyroxine d. Progesterone 2/Which of the following is a function of tropomyosin in skeletal muscle? Select one: a. Binding to myosin during contraction - b. Releasing Ca+2 after initiation of contraction c. Acting as a relaxing protein d. Sliding on actin to produce shortening 3/Absorption of which of the following nutrients will be affected by total removal of stomach? Select one: _ a. Vitamin K _...
The effects of testosterone include choose one? a. A decrease in basal metabolic rate. b. Skin...
The effects of testosterone include choose one? a. A decrease in basal metabolic rate. b. Skin thins and becomes drier. c. Bone density increases. d. Hair growth slows down. e. All of the above choices are correct. Which of the following events occurs during meiosis II? Select one: a. Production of 4 genetically distinct daughter cells b. Crossing over of homologous chromosomes c. Production of 2 haploid daughter cells d. Production of 4 identical, diploid daughter cells e. DNA replication...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT