/* Laboratory Assignment For Tuesday 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) + A(a,d,n) where F(n) : n-th term in the Fibonacci series (i.e., 1,1,2,3,5,8,13,...), A(n) : n-th term in the Arithmetic Series, i.e., (a+(n-1)*d). The method should have n, a and d (all int) as input parameters. */ class SeriesNew { public void generate(int n,int ai ,int d) { System.out.println("THE SERIES IS:: " ); int i,a,b,fn,an; 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; } an = (ai + (i-1)*d); System.out.print("\t" + (fn+an)); } System.out.println("\n"); return; } } class soln9tue2 { public static void main(String args[]){ MainWindow mainWindow; InputBox inputBox; boolean out ; mainWindow = new MainWindow(); mainWindow.setVisible(true); inputBox = new InputBox(mainWindow); SeriesNew b = new SeriesNew(); 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); } }