Hello all, when i try to run my program I get the following run time error.
Please enter 6 integers followed by a space.
12 3 4 5 6 7
Exception in
thread "main" java.lang.NumberFormatException:
at java.lang.Integer.parseInt(Integer.java:435)
at java.lang.Integer.parseInt(Integer.java:463)
at change.main(change.java:53)
Press any key to continue . . .
First of all what does that mean.
here what i got
public class change {
public static void main(
String[] args) {
System.out.println("Please enter 6 integers followed by a space.");
String input;
input=Stdin.readln(); //read input from keyboard (console).
int blank = input.indexOf(" ");
String pen = input.substring(0, blank); // Reads first number.
//manipulating strings
String first= input.substring(blank+1, input.length()); // Reads rest of the string.
int blank2= first.indexOf(" ");
String nick= first.substring(0, blank2);
String second= input.substring(blank2+1, input.length());
int blank3= second.indexOf(" ");
String dime= second.substring(0, blank3);
String third = input.substring(blank3+1, input.length());
int blank4= third.indexOf(" ");
String quart= third.substring(0, blank4);
String fourth= input.substring(blank4+1, input.length());
int blank5=fourth.indexOf(" ");
String loon = fourth.substring(0, blank5);
String toon= input.substring(blank5+1);
// convert strings to integers.
int pen1=Integer.parseInt(pen);
int nick1=Integer.parseInt(nick);
int dime1=Integer.parseInt(dime);
int quart1=Integer.parseInt(quart);
int loon1=Integer.parseInt(loon);
int toon1=Integer.parseInt(toon);
//Calculate total amount in cents.
int cents=(pen1*1) + (nick1*5) + (dime1*10) + (quart1*25) + (loon1*100) + (toon1*200);
//Calculate total amount in dollars.
int dollars = (cents/100);
System.out.println(dollars + cents); // Prints out the total amount of money.
}
}