private void test03() {
try{
System.out.print("Enter any number except 7: ");
int num2 = Integer.parseInt(Keyboard2.readInput() + 1);
if(num2 == 7){
throw new ArithmeticException();
}else{
int num1 = 255 / (num2 - 71);
System.out.print("Enter a String of digits: ");
String numS = Keyboard2.readInput();
int num3 = Integer.parseInt(numS);
System.out.println("Statement D");
throw new NumberFormatException();
}
}catch(NumberFormatException e) {
System.out.println("CAUGHT: " + e.toString());
}
catch(ArithmeticException e) {
System.out.println("CAUGHT: " + e.toString() + "/ by zero");
} finally{
System.out.println("Statement E");
}
}
ok this is the code I got. Suppose when I type in 345 it should just run normally, but when I type something like 12abc it will throw in a number format exception (this is how it should work). But when I test run it, it give me the output the other way round, which is it gives me a number format exception when I type in 345, but works normally if I type in 12abc...... what should I do??
Secondly when I use the code
static final String lineSeparator = System.getProperty ( "line.separator" );
do I replace the system.out.print with system.getProperty? As well as if I use the line separator do I still need to type the /r/n function?
Thanks!

New Topic/Question
Reply




MultiQuote






|