/* Laboratory Assignment For Wednesday 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) + G(a,r,n) where F(n) : n-th term in the Fibonacci series (i.e., 1,1,2,3,5,8,13,...), G(a,r,n) : n-th term in the Geometric Series, i.e., (a*r^n). The method should have n, a and d (all int) as input parameters. */ class SeriesNew { public void generate(int n,int ai ,int r) { System.out.println("THE SERIES IS:: " ); int i,a,b,fn,gn; a=1;b=1; gn = ai; for(i=1;i<=n;i++) { if(i==1 || i==2) fn=1; else { fn = a+b; a=b; b=fn; } if(i==1) gn=ai; else gn = gn * r; System.out.print("\t" + (fn+gn)); } System.out.println("\n"); return; } } class soln9wed2 { 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 r"); b.generate(n,a,d); } }