/* Laboratory Assignment For Monday of Week of 4/10/04 2) Write a FOR loop based program which prints the first n terms of the following series S(a,d,n) = F(n) - H(a,d,n) where F(n) : n-th term in the Fibonacci series (i.e., 1,1,2,3,5,8,13,...), H(n) : n-th term in the Harmonic Series, i.e., 1/(a+(n-1)*d). The method should have n, a and d (all int) as input parameters. */ class Series { public void generate(int n,int ai ,int d) { System.out.println("THE SERIES IS:: " ); int i,a,b,fn; double hn; a=1;b=1; for(i=1;i<=n;i++) { if(i==1 || i==2) fn=1; else { fn = a+b; a=b; b=fn; } hn = 1.0/(ai + (i-1)*d); System.out.print("\t" + ((double)fn-hn)); } System.out.println("\n"); return; } } class soln9mon2 { public static void main(String args[]){ MainWindow mainWindow; InputBox inputBox; boolean out ; mainWindow = new MainWindow(); mainWindow.setVisible(true); inputBox = new InputBox(mainWindow); Series b = new Series(); int n,a,d; n= inputBox.getInteger("Please enter the value of n"); a=inputBox.getInteger("Please enter the value of a"); d=inputBox.getInteger("Please enter the value of d"); b.generate(n,a,d); } }