-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQB 659.java
More file actions
35 lines (26 loc) · 735 Bytes
/
QB 659.java
File metadata and controls
35 lines (26 loc) · 735 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
//QB 659
//PASSING AN OBJECT TO METHOD
import java.util.*;
class run {
public static void main(String args[]) {
Power ab = new Power();
Scanner sc = new Scanner(System.in);
System.out.println("Enter the Number ");
ab.num = sc.nextInt();
System.out.println("Enter the value of Power");
ab.pow = sc.nextInt();
Power pq = ab.findPow(ab);
System.out.println("power of given number is " + pq.result);
}
}
class Power {
int num, pow, result = 1;
Power findPow(Power obj) {
int i;
Power obj1 = new Power();
for (i = 1; i <= obj.pow; i++) {
obj1.result = obj1.result * obj.num;
}
return obj1;
}
}