Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

There will actually be 3 versions of this project. Part 2 will build on Part 1 a

ID: 3884827 • Letter: T

Question

There will actually be 3 versions of this project. Part 2 will build on Part 1 and Part 3 will build on Parts 1 and 2. Part 1. The rating of metabolic equivalents (MET) is used to describe the intensity units to each activity. Based on the MET value of the activity and the length of time you spent performing it, you can calculate the number of calories you burned by an activity. Your weight (in kg) and the duration of the activity (in minutes) are used to calculate the Calories burned by exercise. If you weigh more then you burn more Calories for that activity. Here is the formula: Calories burned by exercise = ((METs * 3.5 * weight in kg)/200) * duration in minutes. Here is a sample run: How much do you weigh, in pounds: 150 How long did you do the activity (in minutes): 10 What is the MET value for your activity? 5 The number of Calories you have burned is: 69.675 You will need to convert the pounds entered to kilograms to do the calculation. The MET values are taken from specific tables. You will find these tables in Moodle. Part 2. Add a password to the beginning of the program. The user must enter CAL2017 to start the program, otherwise give the message "The password you have entered is not correct". Only give the user one chance to get in the program. Are you using sequence, if, or loop for this? Part 3. Modify the program so it starts out (after the correct password) asking if the user wants to compute the number of Calories burned. If they do, then go through the calculations. Compute the total Calories burned, the average Calories burned and count how many times the calculations have been done. Should the average calculation be done every time the user enters data? Also, when one Calorie calculation is complete, ask the user "Do you want to compute another Calorie Calculation?"

Explanation / Answer

Here the C program is written to follow the tasks -

#include<stdio.h>
#include<stdlib.h>
#include<string.h>//to use string functions
int main()
{
int ch =1 ;
float calories ;
float weigh_p , weight_in_kgs , duration_in_minutes , METs ;
char password[7]="CAL2017";
char s[20];//user's entered password
printf("Enter password ");
scanf("%s",s);
if(strcmp(s,password)==0)//if s and password are same then strcmp(s,password)=0
{
while(ch)
{
printf("How much do you weigh in pounds : ");
scanf("%f",&weigh_p);
weight_in_kgs =2.20462 * weigh_p;
printf("How long did you do the activity y(in minutes ) : ");
scanf("%f",&duration_in_minutes);
printf("What is the MET value for your activity ? : ");
scanf("%f",&METs);
calories = (METs * 3.5 * weight_in_kgs / 200 )* duration_in_minutes ;

//resulting output
printf("The number of calories you have burned is : %f ",calories);
  
//decision making for more solutions
printf("Do you want to calculate more calories ? Enter 1 to continue or 0 to exit ");
scanf("%d",&ch);
}
}
else
{
printf("Wrong password , try again ");
}
return 0;
}

Ouptut-

aashish@aashish ~/Desktop/My_D/chegg $ ./a.out
Enter password
kjdga
Wrong password , try again

aashish@aashish ~/Desktop/My_D/chegg $ gcc MET.c
aashish@aashish ~/Desktop/My_D/chegg $ ./a.out
Enter password
CAL2017
How much do you weigh in pounds : 150
How long did you do the activity y(in minutes ) : 10
What is the MET value for your activity ? : 5
The number of calories you have burned is : 289.356384

Do you want to calculate more calories ?
Enter 1 to continue or 0 to exit
1   
How much do you weigh in pounds : 230
How long did you do the activity y(in minutes ) : 15
What is the MET value for your activity ? : 4
The number of calories you have burned is : 532.415710

Do you want to calculate more calories ?
Enter 1 to continue or 0 to exit

0

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote