Question

In: Computer Science

Many exercise apps record both the time and the distance a user covers while walking, running,...

Many exercise apps record both the time and the distance a user covers while walking, running, biking, or swimming. Some users of the apps want to know their average pace in minutes and seconds per mile, while others want to know their average speed in miles per hour. In many cases, we are interested in projected time over a specific distance. For example, if I run 6.3 miles in 53 minutes and 30 seconds, my average pace is 8 minutes and 29 seconds per mile, my average speed is 7.07 miles per hour and my projected time for 2.7 miles is 22 minutes and 55 seconds. Your job in Part 2 of this homework is to write a program that asks the user for the minutes, seconds, miles run, and miles to target from an exercise event and outputs both the average pace and the average speed. You can expect minutes and seconds to both be integers, but miles will be a float. All minutes and seconds must be maintained as integers so please use integer division and modulo operations. Note that if you have a float value then the function int gives you the integer value.

For example:

>>> x = 29.52

>>> y = int(x)

>>> print(y) 29

The output for the speed will be a float and should be printed to 2 decimal places. Notice also that our solution generates a blank line before the output of calculations.

Solutions

Expert Solution

miles = float(input('Enter the miles you have run for: '))
mins = int(input('Enter the minutes you have run for: '))
seconds = int(input('Enter the seconds you have run for: '))

milesTargetted = float(input('Enter the miles you are targetting for: '))

totalTimeInSecs = mins * 60 + seconds

avgPaceInSecs = int(totalTimeInSecs / miles)
print("Averaeg pace is %d minutes and %d seconds per mile" % (avgPaceInSecs // 60, avgPaceInSecs % 60))

avgSpeed = (miles * 3600) / (totalTimeInSecs)
print("Averaeg speed is %.2f miles per hour" % (avgSpeed))

projectedTimeInSecs = milesTargetted * totalTimeInSecs / miles
print("Projected time for %.2f miles is %d minutes and %d seconds" % (milesTargetted, projectedTimeInSecs // 60, projectedTimeInSecs % 60))
**************************************************

Thanks for your question. We try our best to help you with detailed answers, But in any case, if you need any modification or have a query/issue with respect to above answer, Please ask that in the comment section. We will surely try to address your query ASAP and resolve the issue.

Please consider providing a thumbs up to this question if it helps you. by Doing that, You will help other students, who are facing similar issue.


Related Solutions

1. Discuss how relative time characteristics of human walking and running gaits are explained by (a)...
1. Discuss how relative time characteristics of human walking and running gaits are explained by (a) motor program-based theory and (b) dynamical systems theory.
Critical thinking exercise 7.4 Do you think a personal health record or other health apps have...
Critical thinking exercise 7.4 Do you think a personal health record or other health apps have the power to change an individual’s health behavior? Why or why not? Critical thinking exercise 7.5 Aside from security concerns, wat reasons might there be for an individual not to create a personal health record?
1. Which is an example of resistance exercise?(Choose the correct answer) A. Long-distance running B.Weight lifting...
1. Which is an example of resistance exercise?(Choose the correct answer) A. Long-distance running B.Weight lifting C.Biking D.Yoga E.Ice skating 2. Recommendations for fluid replacement after exercise is:(Choose the correct answer) A. 2 to 3 cups of water for every pound of body weight lost B. 1 cup of water for every pound of body weight lost C. 5 to 7 cups of water for every pound of body weight lost D. 3 to 5 cups of water for every...
C++ while loop Exercise Write a program that continues to ask the user to enter any...
C++ while loop Exercise Write a program that continues to ask the user to enter any set of numbers, until the user enters the number -1. Then display the total sum of numbers entered and their average. (note that you need to define a counter that counts how many numbers so the average = (sum/n) where n is your counter total. #include <iostream> using namespace std; int main() { int number, n=0, sum=0; cout << "Enter a number to start...
A mid-distance running coach claims that his six-month training program significantly reduces the average time to...
A mid-distance running coach claims that his six-month training program significantly reduces the average time to complete a 1500-meter run. Five mid-distance runners were randomly selected before they were trained with the coach’s six-month training program and their completion time of 1500-meter run was recorded (in minutes). After six-months of training under the coach, the same five runner’s 1500 meter run time recorded again, the results are given below. Runner 1 2 3 4 5 Completion time before training 5.9...
You are running with a business since last many years. Over a period of time you...
You are running with a business since last many years. Over a period of time you have very good corporate image in market. But unfortunately since last two years your firm is passing through crisis. Your business is suffering from heavy losses. You are planning to wind up your business. Meanwhile one big corporate house has announced a big corporate deal through auction. You have also decided to take part in that deal as it will be a last option...
MEN Time (minutes and seconds) Exercise per Week Favorite Exercise 1 1:48 6 Running 2 1:11...
MEN Time (minutes and seconds) Exercise per Week Favorite Exercise 1 1:48 6 Running 2 1:11 4 Walking 3 0:32 2 Push up 4 0:47 3 Jumping Jacks 5 0:18 0 n/a WOMEN Time (minutes and seconds) Exercise per week Favorite Exercise 1 0:35 2 Squats 2 1:20 3 Elliptical machine 3 1:14 5 Squats 4 1:09 0 n/a STEP 3: You will analyze your data and compute the following statistics for each group: 1) The Mean and standard deviation...
Just-in-time (JIT) processing gained popularity in Japan. While it is being used successfully by many US businesses,...
Just-in-time (JIT) processing gained popularity in Japan. While it is being used successfully by many US businesses, its use by domestic enterprises may never achieve the level of implementation and degree of integration found in Japan. What obstacles do US organizations face that make it more difficult for them to implement JIT than their counterparts in Japan?
When Susan rides her bike, the distance that she travels varies directly with the amount of time she is biking. Suppose she bikes 50 miles in 2.5 hours. At this rate, how many hours would it take her to bike 80 miles?
When Susan rides her bike, the distance that she travels varies directly with the amount of time she is biking. Suppose she bikes 50 miles in 2.5 hours. At this rate, how many hours would it take her to bike 80 miles?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT