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 3.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 3.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 25 minutes, 15 seconds after 17:45:00, which is 18:11:15 Within your Labi w folder, write a program named Running Time 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 inilos rum. 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 pvce would end the run at 0:14:48 the next day. In fact, it's even possible for the ending time to be inore than one day after the starting time. For example, starting a 100-unile 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 prograin is running. What time did you start your run? Hour (0-23) - 17 Minute (0-59) - 45 Second (0-59) - 9 How many miles did you run? 3 What was your per-nile pace? Minute (0-59) - 8 Second (0-59) - 45 Your ending time 18 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 ininute or second is a single digit. We will soon cover the prograinining mechanisins you need to do this, but not just yet

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

Professional Microsoft SQL Server 2012 Administration

Authors: Adam Jorgensen, Steven Wort

1st Edition

1118106881, 9781118106884

More Books

Students also viewed these Databases questions