Results 1 to 2 of 2
- 01-23-2009, 11:08 AM #1
Member
- Join Date
- Oct 2008
- Posts
- 39
- Rep Power
- 0
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
- 01-23-2009, 04:13 PM #2
Similar Threads
-
trouble with Scanner(new File("input"));
By ronyosi in forum New To JavaReplies: 9Last Post: 10-27-2010, 11:34 PM -
Exception in thread "main" javax.naming.NameNotFoundException: jmx not bound
By Vartika in forum Advanced JavaReplies: 2Last Post: 08-07-2009, 10:21 PM -
Can't get my "if" statement to read user input
By daletron3030 in forum New To JavaReplies: 7Last Post: 01-16-2009, 05:24 AM -
the dollar sign "$", prints like any other normal char in java like "a" or "*" ?
By lse123 in forum New To JavaReplies: 1Last Post: 10-20-2008, 07:35 AM -
Exception in thread "main" java.net.ConnectException: Connection timed out
By osval in forum Advanced JavaReplies: 1Last Post: 07-27-2007, 10:59 PM
Bookmarks