- 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
- ----------------------------------error-----------------------------
- do {
- System.out.println("The effective radius for radius" + wheelRadius + "and sprockets" + frontSprocket + " and " + rearSprocket + " is " + eftRadius1 );
- } while (eftRadius1 > 0);
- System.out.println("The effective radius for radius" + wheelRadius + "and sprockets" + frontSprocket + " and " + rearSprocket + " is " + eftRadius1 );
- eftRadius1--;
- --------------------------error-----------------------------------------
- its work fine & run up to zero value But its start my calculation from E.g ( The effective radius for radius 27.5 and sprockets 55 and 23 is 65.77 Right ) But its give me result from here
- The effective radius for radius 27.5 and sprockets 55 and 23 is 42.77 ( Wrong )
- //calculate and print ratio
- ratio = eftRadius/pRadius;
- System.out.println("ratio to previous " + ratio );
- } // end of main
- } // end class
- Reply With Quote

By: lolo | Date: Mar 5 2009 15:56 | Format: None | Expires: never | Size: 2 KB | Hits: 851
Latest pastes
1 days ago
3 days ago
4 days ago
5 days ago
6 days ago