Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: ProcessBicycleGears Program Problem

  1. #1
    Junior Member
    Join Date
    Jan 2011
    Location
    Wales
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default ProcessBicycleGears Program Problem

    // 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
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: ProcessBicycleGears Program Problem

    Cross posted at ProcessBicycleGears Program Problem. While cross-posting is not against the rules of this forum, I recommend you be forthright in revealing where else your question was posted. For reasons why, see The problems with crossposting

  3. #3
    Junior Member
    Join Date
    Jan 2011
    Location
    Wales
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: ProcessBicycleGears Program Problem

    Mods could you delete thisd thread for me
    Last edited by welsh_rocker; February 10th, 2011 at 03:59 PM.

Similar Threads

  1. converter program, problem with action listener
    By robertson.basil in forum What's Wrong With My Code?
    Replies: 2
    Last Post: October 2nd, 2010, 05:44 AM
  2. [SOLVED] Problem with a tutorial program(Adding the answer of two squared numbers together)
    By Melawe in forum What's Wrong With My Code?
    Replies: 20
    Last Post: April 7th, 2010, 09:03 AM
  3. Tic-Tac-Toe program problem help
    By MuffinMcFluffin in forum What's Wrong With My Code?
    Replies: 3
    Last Post: December 25th, 2009, 10:14 PM