Computer Science, asked by mrsudhirkumarsingh8, 8 months ago

Two numbers are entered through the keyboard. Write a program to find the value of one number
raised to the power of another (Do not use Java built-in method)
pls do with SCANNER​

Answers

Answered by crpiyushbansal
9

Answer:

package com.company;

import java.util.Scanner;

public class power {

   public static void main(String[] args) {

       Scanner sc = new Scanner(System.in);

       System.out.println("ENTER THE NO. ");

       int n1 = sc.nextInt();

       System.out.println("ENTER THE POWER FOR THAT NO.");

       int n2 = sc.nextInt();

       int power = 1;

       if (n2 >= 1) {

           for (int i = 1; i <= n2; i++) {

               power = power * n1;

           }

           System.out.println(power);

       }

   }

}

Explanation:

Similar questions