# ProcessBicycleGears Program Problem

Printable View

• 02-10-2011, 09:14 PM
welsh_rocker
ProcessBicycleGears Program Problem
Code:

```// Find effective radius public class ProcessBicycleGears {       public static double PromptAndRead (String prompt)     {     double input;     UserInput.prompt(prompt);     input = UserInput.readDouble();         while (input <=0)     {         System.out.println(" Error invalid data ");         input = (int)PromptAndRead (" Please input data again: ");         // Prompt and read the rear teeth     }         return input; }     public static double CalcEffectiveRadius (double wRadius, int fSprocket, int rSprocket)     {         double eRad = (wRadius * fSprocket) / rSprocket;         // put your local declarations here         return eRad;     }         public static void main(String[] argv) {         int frontSprocket, rearSprocket;         double eRadius, wheelRadius, newRadius, ratio;         // put your local declarations here                 wheelRadius = PromptAndRead(" Type the Radius: ");         // Prompt and read the inches         frontSprocket = (int)PromptAndRead (" Type the front teeth: ");         // Prompt and read the front teeth                 rearSprocket = (int)PromptAndRead (" Type the rear teeth: ");         // Prompt and read the rear teeth                 eRadius = CalcEffectiveRadius(wheelRadius, frontSprocket, rearSprocket);         //Declares effective radius calculation                 System.out.println(" Effective radius for " + frontSprocket + " and teeth "         + rearSprocket + " is " + eRadius);         // Compute and print             newRadius = eRadius;             //Calculates the new effective radius           do  {             rearSprocket = (int)PromptAndRead (" Type the rear teeth: ");             // Prompt and read the rear teeth             ratio = eRadius % newRadius; //Declares Ratio Calculation             System.out.println(" Effective radis for " + frontSprocket +             " and teeth " + rearSprocket + " is " + newRadius + " ratio to previous " + ratio);             newRadius = (wheelRadius * frontSprocket) / rearSprocket;             newRadius = newRadius;             ratio--;             //Delcares Output from Loop     } while (rearSprocket >0);     } // end of main } // end class```
Hey guys I have to build a program for an assignment that uses 2 constructors for calculations and input I have implemented those features into the program and they run fine, but I am still having problems with the second series of the program that implements a while Do while Loop to do the effective Radius Calculation and out out the overall ratio could someone take a look at my code and tell me where I'm going wrong if possible?
• 02-10-2011, 09:29 PM
doWhile
• 02-10-2011, 09:33 PM
welsh_rocker
Quote:

Originally Posted by doWhile

Hey sorry this program has been really stressing me out today for a solution for the problems with the calculations.
• 02-10-2011, 09:50 PM
welsh_rocker
Hey mods I just posted this message on the same forum could you delete this thread for me.