forked from deepdalsania/tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest_Throw.java
More file actions
38 lines (33 loc) · 861 Bytes
/
Test_Throw.java
File metadata and controls
38 lines (33 loc) · 861 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package test;
import java.util.Scanner;
@SuppressWarnings("serial")
public class Test_Throw extends Exception {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
float a, b;
Scanner s = new Scanner(System.in);
try {
System.out.println("Enter 2 num");
a = s.nextFloat();
b = s.nextFloat();
s.close();
if (a < 0.2 || b < 0.2) {
throw new Test_Throw();
}
System.out.println("multiplication = " + (a * b));
} catch (Test_Throw e) {
// TODO: handle exception
System.out.println("Exception : Numbers are too small");
System.out.println("Re-enter value of num ");
a = s.nextFloat();
b = s.nextFloat();
System.out.println("multiplication = " + (a * b));
} catch (NumberFormatException e1) {
// TODO: handle exception
System.out.println(e1);
}
}
}