Question

In: Computer Science

Finish the calories_burned_functions.py program that we started in class. Take the original calories_burned program and rework...

Finish the calories_burned_functions.py program that we started in class. Take the original calories_burned program and rework it so that it uses two functions/function calls.

Use the following file to get your program started:

"""

''' Women: Calories = ((Age x 0.074) - (Weight x 0.05741) + (Heart Rate x 0.4472) - 20.4022) x Time / 4.184 '''
''' Men: Calories = ((Age x 0.2017) + (Weight x 0.09036) + (Heart Rate x 0.6309) - 55.0969) x Time / 4.184 '''
"""
#Declare Variable names and types

age_years = int(input())
weight_pounds = int(input())
heart_bpm = int(input())
time_minutes = int(input())

#Performing Calculations

calories_woman = ( (age_years * 0.074) - (weight_pounds * 0.05741) + (heart_bpm * 0.4472) - 20.4022 ) * time_minutes / 4.184

calories_man = ( (age_years * 0.2017) + (weight_pounds * 0.09036) + (heart_bpm * 0.6309) - 55.0969 ) * time_minutes / 4.184

#Print and format results in detail

print('Women: {:.2f} calories'.format(calories_woman))
print('Men: {:.2f} calories'.format(calories_man))

"""

#Here are the functions to this program

def calc_calories_woman(years, pounds, heartrate, minutes):
  
return ( (age_years * 0.074) - (weight_pounds * 0.05741) + (heart_bpm * 0.4472) - 20.4022 ) * time_minutes / 4.184

#This is the main part of the program

#------------------------------------------------------------------------------

#Prompt the user at the keyboard for the necessary information

age_years = int(input("Please enter your age: "))
weight_pounds = int(input("Please enter your weight: "))
heart_bpm = int(input("Please enter your heart rate: "))
time_minutes = int(input("Please enter the time: "))

#Calculate the calories

calories_woman = ( (age_years * 0.074) - (weight_pounds * 0.05741) + (heart_bpm * 0.4472) - 20.4022 ) * time_minutes / 4.184

calories_man = ( (age_years * 0.2017) + (weight_pounds * 0.09036) + (heart_bpm * 0.6309) - 55.0969 ) * time_minutes / 4.184

#Print the results

print('Women: {:.2f} calories'.format(calories_woman))
print('Men: {:.2f} calories'.format(calories_man))

Solutions

Expert Solution

#include <stdio.h>

//function to calc calories of woman
double calc_calories_woman(int age_years,int weight_pounds,int heart_bpm,int time_minutes){
    return ( (age_years * 0.074) - (weight_pounds * 0.05741) + (heart_bpm * 0.4472) - 20.4022 ) * time_minutes / 4.184;
}

//function to calc calories of man

double calc_calories_man(int age_years,int weight_pounds,int heart_bpm,int time_minutes){
    return ( (age_years * 0.2017) + (weight_pounds * 0.09036) + (heart_bpm * 0.6309) - 55.0969 ) * time_minutes / 4.184;
}

int main()
{
    //Getting The Inputs
    int age_years = 0;
    printf("Please enter your age: ");
    scanf("%d",&age_years);
    int weight_pounds = 0;
    printf("Please enter your weight: ");
    scanf("%d",&weight_pounds);
    int heart_bpm = 0;
    printf("Please enter your heart rate: ");
    scanf("%d",&heart_bpm);
    int time_minutes = 0;
    printf("Please enter the time: ");
    scanf("%d",&time_minutes);
    
    //print the final result and calling the calc_calories function  
    printf("Women: %.2f calories\n",calc_calories_woman(age_years,weight_pounds,heart_bpm,time_minutes));
    printf("Men: %.2f calories",calc_calories_man(age_years,weight_pounds,heart_bpm,time_minutes));
    return 0;
}

Output:


Related Solutions

((PYTHON)) Finish the calories_burned_functions.py program that we started in class. Take the original calories_burned program and...
((PYTHON)) Finish the calories_burned_functions.py program that we started in class. Take the original calories_burned program and rework it so that it uses two functions/function calls. Use the following file to get your program started: """ ''' Women: Calories = ((Age x 0.074) - (Weight x 0.05741) + (Heart Rate x 0.4472) - 20.4022) x Time / 4.184 ''' ''' Men: Calories = ((Age x 0.2017) + (Weight x 0.09036) + (Heart Rate x 0.6309) - 55.0969) x Time / 4.184...
JAVA PROGRAM: FINISH THE FOLLOWING METHOD IN THE CLASS BasicBioinformatics. public class BasicBioinformatics { /** *...
JAVA PROGRAM: FINISH THE FOLLOWING METHOD IN THE CLASS BasicBioinformatics. public class BasicBioinformatics { /** * Calculates and returns the reverse complement of a DNA sequence. In DNA sequences, 'A' and 'T' * are complements of each other, as are 'C' and 'G'. The reverse complement is formed by * reversing the symbols of a sequence, then taking the complement of each symbol (e.g., the * reverse complement of "GTCA" is "TGAC"). * * @param dna a char array representing...
A student is considering whether to finish their university program in four​ consecutive​ years, or take...
A student is considering whether to finish their university program in four​ consecutive​ years, or take a year off and work for some extra​ cash.​ ​​Required: ​​a. Identify at least two revenues or costs that are relevant to making this decision. Explain why each is relevant. ​​b. Identify at least two costs that would be considered sunk costs for this decision. ​​c. Comment on at least two qualitative consideration for this decision.
We started creating a Java class for Car. In this lab we are going to complete...
We started creating a Java class for Car. In this lab we are going to complete it in the following steps: 1- First create the Car class with some required instance variables, such make, model, year, price, speed, maxSpeed, isOn, isMoving, and any other properties you like to add. 2- Provide couple of constructors for initializing different set of important properties, such as make, model, year, and price. Make sure that you do not repeat initialization of instance variables in...
We started class with an overview of ancient schools of Greek thought, and we are finishing...
We started class with an overview of ancient schools of Greek thought, and we are finishing with the branching out of psychological science from the basic schools of thought that it had established by 1970 or so (Humanistic, Behavioral, Psychoanalytical, and Cognitive). Please match these major areas of psychology to the early Greek thinkers (Plato, Homer, Aristotle, and Heraclitus). Include in your response the ideas of personality differences, cognitive processing, etc.... how did each of the major schools of thought...
We started off this class by looking at the data about Small Businesses to understand the...
We started off this class by looking at the data about Small Businesses to understand the importance of data to the success of the US economy and its significance in the world. Throughout the class, we examined the best management practices for small business managers and owners to increase the chance for success. The Small Business Administration (SBA) has offered some additional facts that may suggest several interesting ideas for the future of small business and its need for good...
In our Eco 207 class, we have a policy that says we take the best three...
In our Eco 207 class, we have a policy that says we take the best three out of four of your exam grades and count then toward your overall course grade. In other words, we drop the lowest score. (below, assume that the professor’s goals are to have the students work hard all semester long, and obtain good grades) a. What part of this policy provides a positive incentive to do well? b. What is problematic about this policy from...
2 runners started a race at the exact same time and tie at the finish. Which...
2 runners started a race at the exact same time and tie at the finish. Which single answer has to be true? A) The two had the same speed, but not exactly at the same time. B) The two had exactly the same speed, at exactly the same time, at one point in the run. C) Their MPH at the end was exactly the same. D) The two were not tied at one point during the run. E) None are...
“take-home assignment” “As you know, we started our lecture at the beginning of the semester ironically...
“take-home assignment” “As you know, we started our lecture at the beginning of the semester ironically with an analysis of the health care system in the US. We discussed the implications of the so-called “The Affordable Care Act” for public finance, which addresses the fundamental questions raised by the controversies over the proper role of the government in dealing with health care issues. As an application (Application 1), we discussed the “Modern Measles Epidemic” talking about negative externalities and government...
During the semester, we have started every class with discussing a current event and analyzing it...
During the semester, we have started every class with discussing a current event and analyzing it from a legal point of view. Finally, we discussed the business implications of such legal assessment and the steps a business-person could take to protect against the risks caused by these events. For instance, during the Chapter on contracts, we discussed the implications of the Coronavirus. First, we discussed how the World Health Organization categorized it then as an epidemic. Then we discussed how...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT