a. Create a class called MarathonRunner that has three private data members: name (String), distance (double) and time (double). b. Write a constructor that accepts name, distance, and time as input parameters to initialize the private data members. C. Provide only one accessor (get) method and one mutator (set) method for the distance data member. d. Define a private method called calculateSpeed() which calculates and returns the speed (double) of the marathon runner. The speed is calculated using the formula: speed e. Define a public method called isFaster() that accepts as input parameter a speed record(double). The method should return true if the current runner's speed is faster than the speed record, otherwise, return false. f Define a public method called displayDetails() to display on the screen the runner's details as in the following sample: distance %3D time

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter10: Classes And Data Abstraction
Section: Chapter Questions
Problem 6SA
icon
Related questions
Question
Java code please
Define a class with the following specifications:
a. Create a class called MarathonRunner that has three private data members: name (String), distance
(double) and time (double).
b. Write a constructor that accepts name, distance, and time as input parameters to initialize the private
data members.
c. Provide only one accessor (get) method and one mutator (set) method for the distance data member.
d. Define a private method called calculateSpeed() which calculates and returns the speed (double) of the
marathon runner. The speed is calculated using the formula: speed
Define a public method called isFaster() that accepts as input parameter a speed record(double). The
method should return true if the current runner's speed is faster than the speed record, otherwise, return
false.
f Define a public method called displayDetails() to display on the screen the runner's details as in the
following sample:
distance
%3D
time
c.
Runner name: Ahmed
Distance traveled: 11700 m
Time elapsed: 2372.0 s
Runner's Speed: 4.93 m/s
Transcribed Image Text:Define a class with the following specifications: a. Create a class called MarathonRunner that has three private data members: name (String), distance (double) and time (double). b. Write a constructor that accepts name, distance, and time as input parameters to initialize the private data members. c. Provide only one accessor (get) method and one mutator (set) method for the distance data member. d. Define a private method called calculateSpeed() which calculates and returns the speed (double) of the marathon runner. The speed is calculated using the formula: speed Define a public method called isFaster() that accepts as input parameter a speed record(double). The method should return true if the current runner's speed is faster than the speed record, otherwise, return false. f Define a public method called displayDetails() to display on the screen the runner's details as in the following sample: distance %3D time c. Runner name: Ahmed Distance traveled: 11700 m Time elapsed: 2372.0 s Runner's Speed: 4.93 m/s
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Study of Characters
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
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning