Hello. I am having a bit of trouble with this code. Its about making a running log using O(n) (linear) notation but I keep having problems figuring it out. I would appreciate the help for figuring out this code. Can you pleae paste it in eclipse format since that is the software I am using. Thanks. This is the problem: Write a program that: Asks the user for number of runs For each run, ask the user What the distance was in miles (in decimal format, e.g. 3.1 miles is acceptable) What the time was in minutes (in decimal format, e.g. 23.9 minutes is acceptable) Output the average pace (in minutes per mile) of all runs. Please paste the code down below. Thanks.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Hello. I am having a bit of trouble with this code. Its about making a running log using O(n) (linear) notation but I keep having problems figuring it out. I would appreciate the help for figuring out this code. Can you pleae paste it in eclipse format since that is the software I am using. Thanks.

This is the problem:

Write a program that:

  1. Asks the user for number of runs
  2. For each run, ask the user
    1. What the distance was in miles (in decimal format, e.g. 3.1 miles is acceptable)
    2. What the time was in minutes (in decimal format, e.g. 23.9 minutes is acceptable)
  3. Output the average pace (in minutes per mile) of all runs.

Please paste the code down below. Thanks.

Expert Solution
Step 1: Providing the algorithm


1. Start the program.

2. Initialize variables:
   - totalDistance to 0.0 (total distance of all runs)
   - totalTime to 0.0 (total time of all runs)

3. Prompt the user for the number of runs:
   - Read and store the number of runs in numberOfRuns.

4. Loop for each run from 1 to numberOfRuns:
   a. Display "Run i:" where i is the current run number.

   b. Prompt the user for the distance in miles for the current run:
      - Read and store the distance in the distance variable.

   c. Prompt the user for the time in minutes for the current run:
      - Read and store the time in the time variable.

   d. Add the distance to totalDistance.
   e. Add the time to totalTime.

5. Calculate the average pace:
   - Divide totalTime by totalDistance and store it in averagePace.

6. Extract minutes and seconds from averagePace:
   - minutes = integer part of averagePace
   - seconds = (averagePace - minutes) * 60

7. Format seconds with two decimal places.

8. Display the average pace:
   - "Average Pace: minutes minutes formattedSeconds seconds per mile."

9. End the program.

10. The program finishes.

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Topological Sort
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education