Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class exponentmethod {
- public static void main (String args []){
- Scanner input = new Scanner (System.in);
- int total = 0 , first = 0 , second = 0 ;
- System.out.print("Enter base");
- first= input.nextInt();
- System.out.print("Enter exponent");
- second= input.nextInt();
- total= a(first, second);
- System.out.print("result"+total);
- }
- static int result=1;
- static int a(int t,int y){
- return result;
- int ctr=1;
- while (ctr!=y){
- result = result * t;
- ++ctr;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement