Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

COP 3804 Assignment 1 in java : Bicycle Madness A racing bicycle is driven by a chain connecting two gear wheels with teeth. Gear wheels

COP 3804 Assignment 1

in java

: Bicycle Madness A racing bicycle is driven by a chain connecting two gear wheels with teeth. Gear wheels are grouped into two groups: the front group (typically consisting of 2 or 3 wheels) and the rear group (typically consisting of between 5 and 10 gear wheels). At any time, the chain connects one of the front gear wheels to one of the rear wheels.

The drive ratio the ratio of the angular velocity of the pedals to that of the wheels is the quotient (n / m) where n is the number of teeth on the rear gear wheel and m is the number of teeth on the front gear wheel. Two drive ratios d1 < d2 are neighboring if there is no other drive ratio such that d1 < d3 < d2 . The spread between a pair of drive ratios d1 < d2 is their quotient: (d2 /d1). Your program must compute the maximum spread between two neighboring drive ratios achieved by a particular pair of front and rear gear wheels.

Input: Input to your program consists of several test cases, followed by a line containing zero (0). Each test case is specified by the following input:

f : the number of gear wheels in the front group;

r: the number of gear wheels in the rear group;

f integers, each giving the number of teeth on one of the wheels in the front group;

r integers, each giving the number of teeth on one of the wheels in the rear group. You may assume that no wheel group has more than 10 wheels and that no wheel has fewer than 10 or more than 100 teeth.

Output: For each test case, output the maximum spread rounded to two decimal places. Here is some sample input (although less than what will be used when I test your programs): Sample Input

2 4

40 50

12 14 16 19

0

Sample Output1.19

Your program must read from standard input and write to standard output. No JOptionPanes, for example.

Use a Scanner(System.in) for input, and use System.out.printf() for output.

I will run your program against a test data file that you will not be able to see.

Strategy tips:

1. Calculate all possible drive ratios and sort them in ascending order. 2. For each pair of consecutive drive ratios, calculate their spread and compare it to the maximum spread you've found so far. At the end of the second loop, you will know the maximum spread!

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

Oracle Database 10g Insider Solutions

Authors: Arun R. Kumar, John Kanagaraj, Richard Stroupe

1st Edition

0672327910, 978-0672327919

More Books

Students also viewed these Databases questions