Java Blog

 
 
 
import java.io.*;

class  harmonicSeries 
{
    public static void main(String args[]) 
    {
         int i,n;
         String s;
        double  sum=0;

         try{
               System.out.println(\"=====HARMONIC SERIES=====\");
               System.out.print(\"Enter value of n : \");
               System.out.flush();

               BufferedReader  ob1 = new BufferedReader(new InputStreamReader(System.in));
               s=ob1.readLine();
               n=Integer.parseInt(s);

               while(n>0)
               {
                       sum=sum+(1.0/n);
                       n--;
               }

               System.out.println(\"Sum of Harmonic Series for value  \\\"\"+s+\"\\\" is  :  \"+ sum);
               }

               catch (Exception e)
               {}
    }
}

    Related Post:
  1. An application that combines several classes and interface

  2. Pass the marks of 10 students from the client side design a servlet, which takes these marks and returns the number of students who obtained first cls

  3. Program to calculate the frequency for different values of C starting from 0.01 to 0.1 in steps of 0.01

  4. Program to declare, initialize and print a 2D array of integers

  5. An applet program to draw circle in center of the canvas

  6. Program to show the use of Bitwise Operator (~) Complement

  7. Develop a RMI based application for addition of two complex numbers

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

  9. Program to display bank account

  10. Given a list of marks ranging form 0 to 100, write a program to compute and print the number of students marks

  11. Program to show the use of Do-While Loop

  12. Program to determine the sum of the following harmonic series for a given value of n

  13. Program to reverse the number eg given no : - 12345, output want :- 54321

  14. Application which takes your marks of six subjects from the client side and displays the percentage that you have obtained

  15. CORBA program for displaying the date and time of the server machine, client machine and the difference between these two date and time

  16. An applet program that display blinking rectangle

  17. Program to show an example of extraction of characters from a StringBuffer objects

  18. Socket program of HTTP Server

  19. Program of inventory management and demonstrating interactive input and output

  20. Define an array of ten String elements each containing an arbitrary string of the form “month/day/year”