Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(8 pts) Problem 2 Suppose you leave your house for a run at 17:45:00 (i.e., exactly 5:45 pm). You run 3 miles at a pace

image text in transcribed
(8 pts) Problem 2 Suppose you leave your house for a run at 17:45:00 (i.e., exactly 5:45 pm). You run 3 miles at a pace of 8:45 (8 minutes, 45 seconds) per mile, meaning that your total time spent running is 24 minutes, 135 seconds (which is equivalent to 26 minutes, 15 seconds). The time when you finish your run is thus 26 minutes, 15 seconds after 17:45:00, which is 18:11:15. Within your Lab1 folder, write a program named RunningTime.java that gets user input for these quantities: Hour, minute, and second when you start your run. The hour should be stored in 24-hour format. Number of miles run. Minute and second pace per mile. Based on that information, the program should calculate and display the time when you complete your run. Since it's possible to do a late-night run, your program should account for situations where the ending time is during the next day. For example, starting at 23:59:48 and running 2 miles at a 7:30 pace would end the run at 0:14:48 the next day. In fact, it's even possible for the ending time to be more than one day after the starting time. For example, starting a 100-mile ultramarathon at 23:00:00 and averaging a pace of 20:00 per mile would end the run at 8:20:00 two days later. Here's an example of what your completed program might look like when you run it. Underlined parts indicate what you type in as the program is running What time did you start your run? Hour (0-23) - 17 Minute (0-59) - 45 Second (0-59) - O How many miles did you run? 3 What was your per-mile pace? Minute (0-59) - 8 Second (0-59) - 45 Your ending time is 18:11:15 Hints: Start by figuring out how many total minutes and seconds have passed during the run Add those total minutes and seconds to your starting time. Carry over the excess seconds (60 and above) into minutes, and the excess minutes into hours. The integer division and mod operations will be very useful here. Make sure that the final hours number is in the range 0-23. Can you use mod? . Don't worry about adding leading zeros when the minute or second is a single digit. We will soon cover the programming mechanisms you need to do this, but not just yet! L

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro SQL Server Wait Statistics

Authors: Enrico Van De Laar

1st Edition

1484211391, 9781484211397

More Books

Students also viewed these Databases questions

Question

using signal flow graph

Answered: 1 week ago

Question

=+2 Why are so many countries bothered by their brain drains?

Answered: 1 week ago