Java Blog

 public class JAVA_069

    static double power(double x,int n)
          return (x*power(x,(n-1)));

       else if(n<0)
          return (1.0/power(x,-n));

          return ((n==0)?1.0:x);

    public static void main(String[] args)
       double x=5.0;

       System.out.println(x + \" to the power 4 is \" + power(x,4)); 
       System.out.println(\"7.5 to the power 5 is \" + power(7.5,5)); 
       System.out.println(\"7.5 to the power 0 is \" + power(7.5,0)); 
       System.out.println(\"10 to the power -2 is \" + power(10,-2)); 

    Related Post:
  1. Program to show the use of the Continue Statement

  2. Program to show the use of If-Else Statement

  3. Program of insertion sort

  4. Program to declare, initialize and print an array of integers

  5. Servlet which takes input from an HTML client page and calculates and outputs the premium amount

  6. Program to print triangle of numbers

  7. Program to read input from the Standard Input Device

  8. Program to show an example of creating a class and using its object

  9. Program that accepts a shopping list of items from the command line and stores them in a vector. Also provide facility to perform operation

  10. An applet program to draw Polygon Graph with given data

  11. Program to show an example of modifying String objects

  12. An applet program to perform quick sort

  13. Program using session tracking capability of Servlets, which displays information of current user session by HttpServletRequest object

  14. Program for calculating area of a circle on server side,when a client sends request along with given radius and then displaying result on client side

  15. Program to declare and initialize Boolean variables and print them on the Standard Output Device

  16. Program to declare, initialize and print a StringBuffer object

  17. Word list program that reads a text file and makes an alphabetical list of all the words in that file. The list of words is output to another file

  18. Program to show an example of Copying i.e. Clonning Objects

  19. Corba program to Write a Echo server and client with UDP server and client

  20. Corba program of Count Client Applet, IDL,Server, Client

Didn't find what you were looking for? Find more on Program to show an example of using a recursive method in a class