Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I need help with this lab that is due tomorrow, I have done problem a but will attach the code to help. It is in
I need help with this lab that is due tomorrow, I have done problem a but will attach the code to help. It is in language C.
3b
3c
3d
Please,Please help with all problems.
3.7 Problem 3b Daily Calorie Expenditure Calculator In the second problem of this lab, we will continue practicing creating functions, using the 3- file format/organization, and using conditional statements. This lab will write a Calorie Calculator program to determine what a person's caloric intake should be for a 24-hour span. The program must make a decision about caloric intake, to maintain current body weight, based on gender, age, weight, and height, and activity level. To determine total daily calorie needs, we first must compute the Basal Metabolic Rate (BMR). The BMR formula is the following: Women: BMR = 655+ (4.35 * weight in pounds) + (4.7 * height in inches) - (4.7 * age in years) Men: BMR = 66 + (6.23 * weight in pounds) + (12.7 * height in inches) - (6.8 * age in years) To determine the total daily calorie needs, your program must apply the following guidelines: 1. Sedentary (little to no exercise): Calories = BMR * 1.2 2. Low activity: Calories = BMR * 1.375 3. Moderate activity: Calories = BMR * 1.55 4. High activity: Calories = BMR * 1.725 5. Extra activity: Calories = BMR * 1.9 Procedure To start, create a Keil project using the same procedures as Lab 1. The only difference is that you should use main3b.c instead of main.c and include both prob3b.c and prob3b.h. Define functions where appropriate! Prompt the user for age (assume 10-99), gender, activity level, weight, and height values. Reuse functions from problem 3a when you can! Output the result. Comment all functions. Similarly, modify the comments at the top of main3b.c and prob3b.c to match your details. Some details: - You can use 'M' or 'F' for gender input. - Use a switch statement on activity level to calculate final calories. Call the lab TA and demonstrate the program working. The TA will enter their own test inputs, if your program outputs the correct values the lab TA will check you off. The TA will also scan through your functions to see if they were done correctly. Example Output: Lab 3 Rev. 3 Advanced C Programming: Functions, Conditionals, and Loops Termite 3.4 (by CompuPhase) COM3 115200 bps, 8N1, no handshake Hello, Lab 31 Problem b - About x Close Settings Clear Age (10-99): 29 Age Calc: 29 Gender (M/F):M Height (Feet): 5 Height (Inches): 5 Weight (Pounds): 190 Weight 190 lbs Activity Levels 1. Sedentary (little to no exercise) 2. Low activity 3. Moderate activity 4. High activity 5. Extra activity Enter activity level: 3 Calories: 2910.900000 3.8 Problem 3c GPA Calculator In the third problem of this lab, we will continue practicing creating functions, using the 3-file format/organization, using conditional statements, and loops. This lab will write a GPA calculator program to determine the GPA of a person who has taken five classes. Grades to Grade Points - A = 4 points - B = 3 points - C = 2 points - D= 1 points - F = 0 points Procedure To start, create a Keil project using the same procedures as Lab 1. The only difference is that you should use main3c.c instead of main.c and include both prob3c.c and prob3c.h. Define functions where appropriate! Comment all functions. Similarly, modify the comments at the top of main3c.c and prob3c.c to match your details. 1. Ask for the grades and credits of five classes. Place each grade and credit into a separate variable (e.g., char gradel, char grade2, int credit], int credit2, etc.). 2. Calculate the amount of grade points for each class (switch statement is appropriate here) 3. Calculate the total sum of credits 4. Calculate the GPA using (2) and (3). 5. Instead of using separate variables for each class, reimplement this problem using arrays (e.g., char grade[5]). You can use pointer notation for arrays if you pass them into functions (Remember that arrays are essentially a pointer to the first element). Lab 3 Rev. 3 Advanced C Programming: Functions, Conditionals, and Loops Example Output: Termite 3.4 (by CompuPhase) - X Settings Clear About Jose COM3 115200 bps, N1, no handshake Hello, Lab 3! Problem Class 1 grade (A-F): A Class 1 credits (1-5): 3 Class 2 grade (A-F): D Class 2 credits (1-5): 2 Class 3 grade (A-F): B Class 3 credits (1-5): 4 Class 4 grade (A-F): A Class 4 credits (1-5): 3 Class 5 grade (A-F): C Class 5 credits (1-5): 2 Total Grade Points: 42 Total Credits: 14 GPA 3.000000 3.9 Problem 3d Error Checking In the fourth problem of this lab, we will continue practicing using conditional statements and loops. For all user inputs in problems 3a 3c, do error checking on an erroneous input, the program should print an error and ask the user again for the input). For example, in problem 3b, if the user enters 'D' for gender, the program should print out "ERROR: D is an invalid input then print out Gender (M/F): again. What is the most appropriate loop here? - - - - 3.7 Problem 3b Daily Calorie Expenditure Calculator In the second problem of this lab, we will continue practicing creating functions, using the 3- file format/organization, and using conditional statements. This lab will write a Calorie Calculator program to determine what a person's caloric intake should be for a 24-hour span. The program must make a decision about caloric intake, to maintain current body weight, based on gender, age, weight, and height, and activity level. To determine total daily calorie needs, we first must compute the Basal Metabolic Rate (BMR). The BMR formula is the following: Women: BMR = 655+ (4.35 * weight in pounds) + (4.7 * height in inches) - (4.7 * age in years) Men: BMR = 66 + (6.23 * weight in pounds) + (12.7 * height in inches) - (6.8 * age in years) To determine the total daily calorie needs, your program must apply the following guidelines: 1. Sedentary (little to no exercise): Calories = BMR * 1.2 2. Low activity: Calories = BMR * 1.375 3. Moderate activity: Calories = BMR * 1.55 4. High activity: Calories = BMR * 1.725 5. Extra activity: Calories = BMR * 1.9 Procedure To start, create a Keil project using the same procedures as Lab 1. The only difference is that you should use main3b.c instead of main.c and include both prob3b.c and prob3b.h. Define functions where appropriate! Prompt the user for age (assume 10-99), gender, activity level, weight, and height values. Reuse functions from problem 3a when you can! Output the result. Comment all functions. Similarly, modify the comments at the top of main3b.c and prob3b.c to match your details. Some details: - You can use 'M' or 'F' for gender input. - Use a switch statement on activity level to calculate final calories. Call the lab TA and demonstrate the program working. The TA will enter their own test inputs, if your program outputs the correct values the lab TA will check you off. The TA will also scan through your functions to see if they were done correctly. Example Output: Lab 3 Rev. 3 Advanced C Programming: Functions, Conditionals, and Loops Termite 3.4 (by CompuPhase) COM3 115200 bps, 8N1, no handshake Hello, Lab 31 Problem b - About x Close Settings Clear Age (10-99): 29 Age Calc: 29 Gender (M/F):M Height (Feet): 5 Height (Inches): 5 Weight (Pounds): 190 Weight 190 lbs Activity Levels 1. Sedentary (little to no exercise) 2. Low activity 3. Moderate activity 4. High activity 5. Extra activity Enter activity level: 3 Calories: 2910.900000 3.8 Problem 3c GPA Calculator In the third problem of this lab, we will continue practicing creating functions, using the 3-file format/organization, using conditional statements, and loops. This lab will write a GPA calculator program to determine the GPA of a person who has taken five classes. Grades to Grade Points - A = 4 points - B = 3 points - C = 2 points - D= 1 points - F = 0 points Procedure To start, create a Keil project using the same procedures as Lab 1. The only difference is that you should use main3c.c instead of main.c and include both prob3c.c and prob3c.h. Define functions where appropriate! Comment all functions. Similarly, modify the comments at the top of main3c.c and prob3c.c to match your details. 1. Ask for the grades and credits of five classes. Place each grade and credit into a separate variable (e.g., char gradel, char grade2, int credit], int credit2, etc.). 2. Calculate the amount of grade points for each class (switch statement is appropriate here) 3. Calculate the total sum of credits 4. Calculate the GPA using (2) and (3). 5. Instead of using separate variables for each class, reimplement this problem using arrays (e.g., char grade[5]). You can use pointer notation for arrays if you pass them into functions (Remember that arrays are essentially a pointer to the first element). Lab 3 Rev. 3 Advanced C Programming: Functions, Conditionals, and Loops Example Output: Termite 3.4 (by CompuPhase) - X Settings Clear About Jose COM3 115200 bps, N1, no handshake Hello, Lab 3! Problem Class 1 grade (A-F): A Class 1 credits (1-5): 3 Class 2 grade (A-F): D Class 2 credits (1-5): 2 Class 3 grade (A-F): B Class 3 credits (1-5): 4 Class 4 grade (A-F): A Class 4 credits (1-5): 3 Class 5 grade (A-F): C Class 5 credits (1-5): 2 Total Grade Points: 42 Total Credits: 14 GPA 3.000000 3.9 Problem 3d Error Checking In the fourth problem of this lab, we will continue practicing using conditional statements and loops. For all user inputs in problems 3a 3c, do error checking on an erroneous input, the program should print an error and ask the user again for the input). For example, in problem 3b, if the user enters 'D' for gender, the program should print out "ERROR: D is an invalid input then print out Gender (M/F): again. What is the most appropriate loop here
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started