Results 1 to 4 of 4
  1. #1
    welsh_rocker is offline Member
    Join Date
    Jan 2011
    Location
    Wales
    Posts
    7
    Rep Power
    0

    Default ProcessBicycleGears Program Problem

    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
    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?

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    6

  3. #3
    welsh_rocker is offline Member
    Join Date
    Jan 2011
    Location
    Wales
    Posts
    7
    Rep Power
    0

    Default

    Quote Originally Posted by doWhile View Post
    Hey sorry this program has been really stressing me out today for a solution for the problems with the calculations.

  4. #4
    welsh_rocker is offline Member
    Join Date
    Jan 2011
    Location
    Wales
    Posts
    7
    Rep Power
    0

    Default

    Hey mods I just posted this message on the same forum could you delete this thread for me.

Similar Threads

  1. Can anyone tell me problem in this program ??
    By sahildave1991 in forum AWT / Swing
    Replies: 3
    Last Post: 07-02-2010, 05:37 PM
  2. Problem with the below program
    By srikanthnambu in forum Java 2D
    Replies: 1
    Last Post: 05-20-2009, 05:43 PM
  3. Gui program problem..
    By mingming2009 in forum Advanced Java
    Replies: 7
    Last Post: 04-03-2009, 05:15 AM
  4. Program problem
    By arindamchkrbrty in forum New To Java
    Replies: 8
    Last Post: 03-10-2009, 04:58 AM
  5. program problem
    By amith in forum AWT / Swing
    Replies: 12
    Last Post: 05-16-2008, 08:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •