Hi, this is my first time taking C++, I registered for the course late and I missed a lot, trying to get caught up but I'm having difficulties, I spent hours sitting here but i'm stuck. I wouldn't want the solution rather than someone telling me where I went wrong. Here's the question and then my code:
One way to measure the amount of energy that is expended during exercise is to use metabolic equivalents (MET). Here are some METS for various activities:
Running 6 MPH: 10 METS
Basketball: 8 METS
Sleeping: 1 MET
The number of calories burned per minute may be estimated using the following formula:
Calories/Minute = 0.0175 x MET x Weight(Kg)
Write a program that calculates and output the total number of calories burned for a 150-pound person who runs 6 MPH for 30 minutes, play basketball for 30 minutes, and then sleep for 6 hours. One kilogram is equal to 2.2 pounds.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
#include <stdio.h>
int main()
{
int Minutes, Weight, MET;
float constant=0.0175;
float Calories;
printf("Enter Weight:");
scanf("%d",&Weight);
printf("Enter Running Speed in MET:");
scanf("%d",&MET);
printf("Enter the duration time in minutes:");
scanf("%d",&Minutes);
Calories= constant*MET*(Weight/2.2);
printf("Your total calories burned is:%.2f\n", &Calories);
return 0;
}
|
Here's the second question:
A government research lab has concluded that an artificial sweetener commonly used in diet soda pop will cause death in laboratory mice. A friend of yours is desperate to lose weight but cannot give up soda pop. Your friend wants to know how much diet soda pop it is possible to drink without dying as a result. Write a program to supply the answer. The program has no input but does have defined constants for the following items: the amount of artificial sweetener needed to kill a mouse, the weight of the mouse, the starting weight of the dieter, and the desired weight of the dieter. To ensure the safety of your friend, be sure the program uses the weight at which the dieter will stop dieting, rather than the dieter’s current weight, to calculate how much soda pop the dieter can safely drink. You may use any reasonable values for these defined constants. Assume that diet soda contains 1/10th of 1% artificial sweetener. Use another named constant for this fraction. You may want to express the percent as the double value 0.001. (If your program turns out not to use a defined constant, you may remove that defined constant from your program.)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
#include <iostream>
int main()
{
const double ArtificialSweetner = 0.001;
double SweetnerMouse, WeightMouse, StartWeight, DesireWeight;
int SodaPop;
printf("Enter Amount of Artificial Sweetner needed to kill a mouse");
scanf("%f",&SweetnerMouse);
printf("What is the weight of the mouse?");
scanf("%d",&WeightMouse);
printf("What is your desired weight?");
scanf("%d",&DesireWeight);
StartWeight = (SweetnerMouse/WeightMouse)*DesireWeight;
SodaPop = (StartWeight/ArtificialSweetner);
printf("Amount of Soda Pop that can kill you is:%.2f",&SodaPop);
return 0;
}
|