Machine Problem

Write a Java program that will ask the user to give base and exponent number and then the program will compute the power of the number.

  I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

package test;


import java.util.Scanner;

/*
 * Power_A_Number.java
 * 
 * Jake Rodriguez Pomperada, MAED-IT, MIT
 * www.jakerpomperada.com  and www.jakerpomperada.blogspot.com
 * jakerpomperada@gmail.com
 * Bacolod City, Negros Occidental Philippines
 * 
 * Machine Problem
 * 
 * Write a Java program that will ask the user to give base and exponent number
 * and then the program will compute the power of the number.
 * 
 */

public class Power_A_Number {

	public static void main(String args[]){

	   Scanner input = new Scanner(System.in);
      
      
      System.out.println();
      System.out.println("\tPower a Number in Java");
      System.out.println();
      System.out.print("\tGive base number : ");
      int base = input.nextInt();
      int temp = base;
      System.out.print("\tGive exponent number : ");
      int exp = input.nextInt();

      for (int i=1; i<exp; i++){
         temp = temp*temp;
      }
      System.out.println();
      System.out.println("\tThe Result is "+base+" power "+exp+" is "+temp);
      System.out.println();
      System.out.print("\tEnd of Program \n");  
      System.out.println();
      input.close();
   }
}

Leave a Reply

Your email address will not be published.