728px

Exponential value for given base in Java

Java version of this program is given bellow :
/**
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package power;

import java.util.Scanner;

/**
 *
 * @author ACHCHUTHAN
 */
public class Exponential {

    int re, rb;

    public Exponential() {
        Scanner input = new Scanner(System.in);
        System.out.println("Enter the base Number :");
        rb = input.nextInt();
        System.out.println("Enter the exponential Number :");
        re = input.nextInt();
    }

    public int getRb() {
        return rb;
    }

    public int getRe() {
        return re;
    }

    public int getExp() {
        int o = 1;
        for (int i = 1; i <= re; i++) {
            o = o * rb;
        }
        return o;
    }

    public static void main(String args[]) {
        Exponential base = new Exponential();
        base.getExp();
        System.out.println("Print the Value of " + base.getRb() + " ^ " + base.getRe() + " = " + base.getExp());
    }
}

Output of this program :

run:
Enter the base Number :
5
Enter the exponential Number :
3
Print the Value of 5 ^ 3 = 125
BUILD SUCCESSFUL (total time: 7 seconds)