Public paste
data
By: lolo | Date: Mar 5 2009 15:56 | Format: None | Expires: never | Size: 2 KB | Hits: 882

  1. public class BicycleGears {
  2.  
  3. public static void main(String[] argv)
  4.  
  5. {
  6. double wheelRadius=0.0f;
  7. float eftRadius=0.0f;
  8. int frontSprocket=0;
  9. int rearSprocket=0;
  10. float pRadius=-0.0f;
  11. double eftRadius1;
  12. float ratio=0.00f;
  13.  
  14.  
  15. //Prompt and read the number;
  16. System.out.println ("Please enter the wheelRadius");
  17. wheelRadius = UserInput.readDouble();
  18. //produce an error message and end program
  19. if(wheelRadius <= 0)
  20. {
  21. System.out.println("Error, invalid value");
  22. System.exit(0);
  23. }
  24. //Prompt and read the number;
  25. System.out.println("Please enter the frontSprocket");
  26. frontSprocket = UserInput.readInt();
  27. //produce an error message and end program
  28.  
  29. if(frontSprocket <= 0)
  30. {
  31. System.out.println("Error, invalid value");
  32. System.exit(0);
  33. }
  34. //Prompt and read the number
  35. System.out.println("Please enter the rearSprocket");
  36. rearSprocket = UserInput.readInt();
  37. //produce an error message and end program
  38. if (rearSprocket <= 0)
  39. {
  40. System.out.println("Error, invalid value");
  41. System.exit(0);
  42. }
  43.  
  44.  
  45. // calculation for radius
  46. eftRadius1 = (wheelRadius*frontSprocket)/rearSprocket;
  47.  
  48. //print radius
  49.  
  50. ----------------------------------error-----------------------------
  51. do {
  52. System.out.println("The effective radius for radius" + wheelRadius + "and sprockets" + frontSprocket + " and " + rearSprocket + " is " + eftRadius1 );
  53.  
  54. } while (eftRadius1 > 0);
  55. System.out.println("The effective radius for radius" + wheelRadius + "and sprockets" + frontSprocket + " and " + rearSprocket + " is " + eftRadius1 );
  56. eftRadius1--;
  57. --------------------------error-----------------------------------------
  58. 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
  59. The effective radius for radius 27.5 and sprockets 55 and 23 is 42.77 ( Wrong )
  60.  
  61.  
  62. //calculate and print ratio
  63. ratio = eftRadius/pRadius;
  64. System.out.println("ratio to previous " + ratio );
  65. } // end of main
  66.  
  67. } // end class
  68. Reply With Quote