File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Help me in this java code Please ! ! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Help me in this java code Please ! !" Watch "Help me in this java code Please ! !" New topic

Help me in this java code Please ! !

Sanjana Shah

Joined: Dec 19, 2009
Posts: 2
Cant figure out the following program. Have to submit it as part of project on Monday! ! ! Please Help

You’ve been given an assorted set of gears. Each gear has a different number of teeth – the notches on a gear that interlock with notches on another gear to transmit speed. You have a couple of belts one coupled to an input and the other for the output. You are given the rpm of the input belt Si and a minimum value So (where So > Si) so that you can increase the speed via a system of gears as shown above
You need to figure out all the possible pairs of gears that can be used to achieve an output rpm >= So.
The input is specified in a file containing test-cases.
• The first line contains the number of gears that are available to you, g.
• The next line contains g numbers indicating the number of teeth on each gear, separated by spaces.
• The next line contains the number of test cases – n
o This is followed by n test cases. Each test case is specified by 2 speed values on a single line. (So here the first test case specifies that you need to design a gear-system that increases Si = 50 rpm to a value above 200 rpm)
20 10 4 6 40 25 100
50 200
35 75


E.g. for raising the speed from 50 to 200, any of the following 9 pairs can be used
[100, 6] [40, 6] [25, 6] [25, 4] [20, 4] [40, 4] [100, 4] [100, 20] [100, 10]
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42913
Welcome to JavaRanch.

Be aware that JavaRanch is NotACodeMill. While we're happy to help people, we like for them to ShowSomeEffort. So: What do you have so far? If you haven't started yet, what ideas have you had?
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 40034
Welcome to the Ranch

Please don't submit an e-mail address.

Closing this thread.

Opening thread again as no longer duplicate.
I agree. Here's the link:
subject: Help me in this java code Please ! !