Results 1 to 2 of 2
  1. #1
    soc86 is offline Member
    Join Date
    Oct 2008
    Posts
    39
    Rep Power
    0

    Default Why "Exception while reading user's input as an int"

    Why am I getting the following output when I try entering my input (27.5)

    "Please enter the wheel radius

    27.5

    Exception while reading user's input as an int"



    Below are my inputs and the corrasponding outputs, where am i going wrong??

    Typical input:
    27.5 55 23 19 15 0

    Corresponding typical output
    The effective radius for radius 27.5 and sprockets 55 and 23 is 65.77
    The effective radius for radius 27.5 and sprockets 55 and 19 is 79.60
    ratio to previous 1.21
    The effective radius for radius 27.5 and sprockets 55 and 15 is 100.83
    ratio to previous 1.266






    public class BicylceGears{

    public static void main (String[]args){

    double wheelRad;
    int fSprocket;
    int rSprocket;
    double eRad=0;
    double ratio;
    double eRadLst=0.0;

    System.out.println("Please enter the wheel radius");
    wheelRad =UserInput.readDouble();

    fSprocket =UserInput.readInt();

    rSprocket =UserInput.readInt();


    if( (wheelRad <= 0.0) || (fSprocket <= 0) || (rSprocket <= 0)){


    System.out.println("message Error, invalid value and do not let your program continue.");

    }else{


    eRad = wheelRad*fSprocket/rSprocket;

    ratio=eRadLst/eRad;

    System.out.println("The effective radius for raduis "+wheelRad+" and sprockets ");
    System.out.println("ratio to previous "+ratio);

    eRadLst= eRad+0.0;

    }
    while (eRad >0.0){


    eRad = wheelRad*fSprocket/rSprocket;

    ratio=eRadLst/eRad;

    System.out.println("The effective radius for raduis "+wheelRad+" and sprockets ");
    System.out.println("ratio to previous "+ratio);

    eRadLst= eRad+0.0;


    }
    }//end main

    }//end class

  2. #2
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Posts
    1,046
    Rep Power
    8

Similar Threads

  1. trouble with Scanner(new File("input"));
    By ronyosi in forum New To Java
    Replies: 9
    Last Post: 10-28-2010, 12:34 AM
  2. Replies: 2
    Last Post: 08-07-2009, 11:21 PM
  3. Can't get my "if" statement to read user input
    By daletron3030 in forum New To Java
    Replies: 7
    Last Post: 01-16-2009, 06:24 AM
  4. Replies: 1
    Last Post: 10-20-2008, 08:35 AM
  5. Replies: 1
    Last Post: 07-27-2007, 11:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •