Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started