Hi Everyone
I have been hard at work on this Java program involving bicycle gears, one of the problems is the while loop, should a user enter a negative number in the inputs then i want the user to re enter it until a positive number comes up however the program is also recognising positves as negatives, i also want the program to print the previous ratio entred but cant think of a formula that would display it.
Sorry if i may have confused you all but it should all make clear in my code, im currenty a beginner programmer and would like to get past these problems, if you have encounted any problems or better alternatives please let me know :-)
Thanks anyway
public class ProcessBicycleGears {
public static void main(String[] argv) {
// put your local declarations here
double radius;
int frontteeth;
int rearteeth;
double eradius;
double ratio;
double pradius;
// Prompt and read the inches
System.out.println("Please enter the inches");
radius = UserInput.readDouble();
// Prompt and read the front teeth
System.out.println("Type the front teeth");
frontteeth = UserInput.readInt();
while (frontteeth <=0);
{
System.out.println("Error, negative input");
System.out.println("Type the front teeth");
frontteeth = UserInput.readInt();
// Prompt and read the rear teeth
System.out.println("Type the rear teeth");
rearteeth = UserInput.readInt();
while (rearteeth <=0);
{
System.out.println("Error, negative input");
System.out.println("Type the rear teeth");
rearteeth = UserInput.readInt();
// Compute and print
eradius = (radius*frontteeth)/rearteeth;
System.out.println("The effective radius for radius" +radius+ "and sprockets" +frontteeth+ "and" +rearteeth+ "is" +eradius);
System.out.println("Ratio to previous" +ratio);
} // end of main
} // end class
}
}