forked from IND-Debugs/Java-Programs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPower.java
More file actions
39 lines (36 loc) · 963 Bytes
/
Copy pathPower.java
File metadata and controls
39 lines (36 loc) · 963 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
package Allprogram;
import java.util.Scanner;
public class Power {
private int a,b;
public void getdata(int a,int b)
{
this.a = a;
this.b = b;
}
public void show_data()
{
int i;
int s = a;
long start = System.currentTimeMillis();
for(i=1;i<b;i++)
{
a =a*s;
}
long end = System.currentTimeMillis();
float sec = (end - start) / 10000F;
System.out.println(sec + " seconds");
System.out.println(" power is " +a);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Power obj = new Power();
Scanner sc2 = new Scanner(System.in);
Scanner sc1 = new Scanner(System.in);
System.out.println(" Enter the number");
int c = sc2.nextInt();
System.out.println(" Enter the power");
int d = sc1.nextInt();
obj.getdata(c,d);
obj.show_data();
}
}