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 represent a bank account

  2. Biological Sequence Allignment Using Dynamic Programing

  3. Program to show the use of Switch Statement for the same statement for several different case labels

  4. Program to append a StringBuffer by StringBuffer, String objects and other Basic Data Types

  5. Program to compute the sum of the digits of a given integer number. eg: I/o=4 then O/p=4+3+2+1=10

  6. Program to show an example of getting at characters in a String

  7. Program of an applet to illustrate BarChart

  8. Program that will read real number from the keyboard and print the following output in one line: small Integer not less The Given Number Largest Int

  9. Program to show the use of Logical AND Operator (&) in If Statements

  10. Program to declare, initialize and print a String object

  11. GUI application in java, which enter the details of a student and on the submit display the details of the student

  12. Program that enabled applet that takes name of the user. Server returns back the number in uppercase clubbed with “HELLO” and display it on applet

  13. An applet program to display moving banner

  14. Program to read command line arguments

  15. Corba program to develop a simple calculator with addition, subtraction, multiplication and division capabilities, data collection from client side

  16. Program to show an example of creating Character Arrays from String objects

  17. Program to declare and initialize Integer variables and print them on the Standard Output Device

  18. An applet program to perform quick sort

  19. Game application in CORBA for which player will guess a number between 1 to 100, which will be compared to the random number generated by the class

  20. An applet program to draw different shapes

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