Question
The problem concerns the "effective radius" of a bicycle gear. The required formula i
explained below. i need to Write a program to read:

the wheel radius (use a "double" as variable type);
the number of teeth on the front sprocket (a "long");
the number of teeth on the rear sprocket (a "long");

.....and compute and print the so called ‘effective radius’.

Method
The effective radius of a bicycle gear is calculated from the radius of the wheel, and the number of teeth on the front and rear chain sprockets, as follows:

Effective radius = radius * teeth on the front sprocket / teeth on the rear sprocket.

We suggest that you read the three items of input data, calculate the result and store in a "double" variable, and then print it. You have five (5) submissions.

Typical Input
27.5 30 15

Typical Output
The effective radius for radius 2E.5 and sprockets 30 and 15 is 55.0

// Find effective radius 
public class BicycleGears {

   public static void main(String[] argv) {

        double wheelradius;
        long frontsprocket;
        long rearsprocket;
        double effectiveradius;

       effectiveRadius = wheelradius * frontsprocke / rearsprocket ;  // ( Is that right ? )
                                                                                                    Blue J giving me error

       System.out.println("wheel radius");
       wheelradius = UserInput.readdouble();
       System.out.println("front sprocket");
       frontsprocket = UserInput.readlong();
       System.out.println("rear sprocket");
       rearsprocket = UserInput.readlong();
       System.out.println("Effective radius");
       effectiveradius= UserInput.readdouble();
       System.out.println("nThe effective radius for radius : " + Effective radius +"and sprockets " + frontsprocket );  // print

   } // end of main

} // end class

Last time been advised used books i did. now i am stuck nothing online to reff to that example :(

effectiveRadius = wheelradius * frontsprocke / rearsprocket ; // ( Is that right ? )

Yes, that looks right except for the typo. You are getting an error (in addition to the typo) because you are using variables that aren't initialized yet. Read in the values, THEN calculate using the formula.

public class BicycleGears {

    public static void main(String[] argv) 

  {
           double wheelRadius=0.0f;
           float eftRadius=0.0f;
           int frontSprocket=0;
           int rearSprocket=0;
           float pRadius=-0.0f;
           double eftRadius1;
           float ratio=0.00f;


//Prompt and read the number;
System.out.println ("Please enter the wheelRadius");
wheelRadius = UserInput.readDouble();  (Now getting error here ) :(:(
//produce an error message and end program 
if(wheelRadius <= 0) 
{
System.out.println("Error, invalid value");
System.exit(0);
}
//Prompt and read the number;
System.out.println("Please enter the frontSprocket");
frontSprocket = UserInput.readInt();
//produce an error message and end program 

if(frontSprocket <= 0) 
{
System.out.println("Error, invalid value");
System.exit(0);
} 
//Prompt and read the number
System.out.println("Please enter the rearSprocket");
rearSprocket = UserInput.readInt();
//produce an error message and end program 
if (rearSprocket <= 0)
{
System.out.println("Error, invalid value");
System.exit(0);
}


// calculation for radius
eftRadius1 = (wheelRadius*frontSprocket)/rearSprocket; 

//print radius 

System.out.println("The effective radius for radius" + wheelRadius + "and sprockets" 
+ frontSprocket + " and " + rearSprocket + " is " + eftRadius1 );
//calculate and print ratio 
ratio = eftRadius/pRadius;
  } // end of main

} // end class

Please some try that in BLUE-J Please Please need help

Post the error message.

wheelRadius = UserInput.readDouble(); (Now getting error here )

What is UserInput? I don't see it in the Java SE documentation. Is it a class provided by Sun? Is it a class you wrote? NetBeans doesn't recognize it as a class. If it's a class variable in a class that you wrote and it isn't static, keep in mind that you are in main, which is a static function and so you can't use your non-static class variables.

Whoops! I didn't see THIS thread before responding to this thread. It's amazing that you would ask for help AFTER posting that.

I fix it working fine :)

*/


   public static void main(String[] argv) {

        double wheelRadius=0.0f;
        float eftRadiuss=0.0f;
        int frontSprockets=0;
        int rearSprockets=0;
        float pRadiuss=-0.0f;
        double eftRadiuss1;


       System.out.println("Please enter the wheelRadius");
       wheelRadius = UserInput.readDouble();
       System.out.println("Please enter the frontSprocket");
       frontSprocket = UserInput.readInt();
       System.out.println("Please enter the rearSprocket");
       rearSprocket = UserInput.readInt();
       eftRadius1 = (wheelRadius*frontSprocket)/rearSprocket; 
       System.out.println("\nThe effective radius for radius" + wheelRadius + "and sprockets" + frontSprocket + " and " + rearSprocket + " is " + eftRadius1 ); // print

Just so you know, an Object oriented approach to solving the problem would involve creating a class called Bicycle that had instance variables such as wheelRadius and the other things you listed above. Then, you would have methods - for example, one method might calculate the effective radius. In this example, in your main, you could just say

System.out.println("The effective radius is " + effectiveRadiusMethod());

Of course, that's just an example. In the Bank Account example you posted in your other thread, it would be much more necessary to do as I said above. In this case, you can get away without doing so. Also, keep in mind, in order to get help, you have to ask specific questions and show that you have attempted the problem yourself. Or, if you aren't sure where the problem lies, you can post code and ask for help. BUT you must, at the least, identify a problem. If you don't identify a problem nobody wants to help you. I'm still open to helping you at this point, although many members might not be... and I don't blame them. Try reading the Daniweb rules - code tags, homework help rules, etc.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.