Java effective radius

I am new to forum / Intel p4
January 20, 2009 at 14:34:04
Specs: Windows XP, 2000
Write a program to read the bicycle wheel radius (a "double") the number of teeth on the front sprocket (an "int") and then to read repeatedly the number of teeth on a rear sprocket (an "int") and compute and print the effective radius until a value of zero is encountered.
At every calculation except the first, print the ratio of the newly computed effective radius to the previous effective radius.
MY problem is how i can use while loop in it to make it zero. well i m going to try different way to use while loop inside to get value zero and then get ratio to work. any help would be usefull.I m learning...as well so i will try just need guide line if its possible.

Thanks all for reading

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();
//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;
System.out.println("ratio to previous " + ratio  );
} // end of main

} // end class 


See More: Java effective radius

Report •


#1
January 21, 2009 at 06:02:03
I think you've misunderstood the question. Use a while loop to read each integer representing the number of sprockets. When you find a 0 in the input, terminate.

Report •
Related Solutions


Ask Question