Wednesday 25 July 2012

Harmonic series

Harmonic Series

Harmonics means wavelengths of the overtones of a vibrating string are 1/2, 1/3, 1/4, etc., of the string's fundamental wavelength.  the phrase harmonic mean likewise derives from music.

Diagram indicate Harmonic series:

Program for Harmonic Series

class Harmonic
{
    public static void main(String args[])
    {
        int i,no;
        double j=0;
        no=5;                        //It shows length of Harmonic series
        while(no>0)
        {
           j=j+(double) 1 / no;
           no--;
        }
        System.out.println("Output of Harmonic Series:"+j);
    }
}


Save this program as                       Harmonic.java

Compile it by using command
                                                      javac Harmonic.java

run this program by using command
                                                
                                                       java Harmonic
OUTPUT will look like:

                                                       Output of Harmonic Series:2.28333333

If you want it some more program then paste your problem statement below on comment line.


ShareThis

Related Posts Plugin for WordPress, Blogger...