-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquestion_5.java
More file actions
61 lines (44 loc) · 894 Bytes
/
question_5.java
File metadata and controls
61 lines (44 loc) · 894 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package EXCEPTION;
import java.util.Scanner;
class myex extends Exception{
public myex() {
// TODO Auto-generated constructor stub
System.out.println("Number should greater than 0");
}
}
class myex2 extends Exception{
public myex2()
{
System.out.println("Number should not be 0");
}
}
public class question_5 {
public static void raise(int c,int d)
{
int z=(int) Math.pow(c, d);
System.out.println(z);
}
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
Scanner input=new Scanner (System.in);
int a=input.nextInt();
int b=input.nextInt();
try
{
if(a<0||b<0)
{
throw new myex();
}
else if(a==0||b==0)
{
throw new myex2();
}
else
{
raise(a,b);
}
}catch(Exception e)
{
}
}
}