Question: 4. Design a class named Bicycle for computing the speed of a bicycle. The class should have a method named speed that has no arguments

 4. Design a class named Bicycle for computing the speed of

4. Design a class named Bicycle for computing the speed of a bicycle. The class should have a method named speed that has no arguments and returns a double that represents the current speed of the bicycle in miles per hour. You may assume that the speed of a bicycle is only dependent on the cadence (rotations per minute) and gear size (diameter in inches), so you may compute speed using the formula gearSize 5,280 speed = x cadence x 60 The gear size of a bicycle is fixed when it is created and cannot be changed, whereas the cadence can change. Add a method named setCadence that takes a double and changes the current cadence of the bicycle. Write code that creates a bicycle object, sets the cadence, and prints the current speed to standard output. Include in your Java code the appropriate access specifier (public or private) for the members of the Bicycle class

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!