Exponential value for given base in Java

Posted By: Java Examples - 4:27 PM

Share

& Comment

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)

About Java Examples

I’m passionate about Web Development and Programming and I go to extreme efforts to meet my passion. I’m a believer of learning the fundamentals first. I try to understand everything little bit more than the average.

0 comments :

Post a Comment

Thank you for vising Java90.blogspot.com

Copyright © 2016 Java Examples ACHCHUTHAN.ORG. Designed by Templateism .