Results 1 to 4 of 4
- 02-10-2011, 08:14 PM #1
Member
- Join Date
- Jan 2011
- Location
- Wales
- Posts
- 7
- Rep Power
- 0
ProcessBicycleGears Program Problem
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?Java 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
- 02-10-2011, 08:29 PM #2
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,609
- Rep Power
- 5
Cross posted at ProcessBicycleGears Program Problem - Java Programming Forums
- 02-10-2011, 08:33 PM #3
Member
- Join Date
- Jan 2011
- Location
- Wales
- Posts
- 7
- Rep Power
- 0
- 02-10-2011, 08:50 PM #4
Member
- Join Date
- Jan 2011
- Location
- Wales
- Posts
- 7
- Rep Power
- 0
Similar Threads
-
Can anyone tell me problem in this program ??
By sahildave1991 in forum AWT / SwingReplies: 3Last Post: 07-02-2010, 05:37 PM -
Problem with the below program
By srikanthnambu in forum Java 2DReplies: 1Last Post: 05-20-2009, 05:43 PM -
Gui program problem..
By mingming2009 in forum Advanced JavaReplies: 7Last Post: 04-03-2009, 05:15 AM -
Program problem
By arindamchkrbrty in forum New To JavaReplies: 8Last Post: 03-10-2009, 04:58 AM -
program problem
By amith in forum AWT / SwingReplies: 12Last Post: 05-16-2008, 08:07 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks