nausheen Active member
| Subject: write a program Sun Feb 10, 2008 7:55 pm | |
| write a program in java tto find the sum of given series S= a/2! + a*a/3! +a*a*a/4! ............a*a*a*a*a*a*a*a*a*a/11! where factorial of 4 means : 4!=4*3*2*1 |
|
amrutha Active member
| Subject: Re: write a program Mon Feb 25, 2008 6:10 pm | |
| import java.io.*; public class series { float S; ISR ir=new ISR(System.in); BR br=new BR(ir); public void prog()throws IOException { System.out.println("Enter a number"); String s =br.readLine(); int a=Integer.parseInt(s); while(a!=0) { for(int i=2;i<=11;i++) { for(int j=1;j<=10;j++) { S=S+Math.pow(a,j)/i; } } } System.out.println("The sum of the series is"+S); } } |
|
amrutha Active member
| Subject: Re: write a program Mon Feb 25, 2008 6:11 pm | |
| just check out whether the output is right. |
|
nausheen Active member
| Subject: Re: write a program Tue Feb 26, 2008 5:44 pm | |
| the output is not coming 1) variable S should be DOUBLE Secondly we have to find the factorial of i and then divide it |
|
SHASHANK N K Active member
| Subject: Re: write a program Tue Feb 26, 2008 11:52 pm | |
| import java.io.*; public class Product { InputStreamReader isr=new InputStreamReader(System.in); BufferedReader bf=new BufferedReader(isr); public void main() throws IOException { int a[][]=new int[3][4]; int b[][]=new int[4][3]; int c[][]=new int[3][3]; for(int i=0;i<3;i++) { for(int j=0;J,4;j++) { a[i][j]=Integer.parseInt(bf.readLine()); } } for(int k=0;k<4;k++) { for(int l=0;l<3;l++) { b[k][l]=Integer.parseInt(bf.readLine()); } } for(int m=0;m<3;m++) { for(int n=0;n<3;n++) { c[m][n]=0; for(int o=0;o<4;o++) { c[m][n]=a[m][o]*b[o][n]+c[m][n]; } } } System.out.println("The resultant matrix is:-"); for(int p=0;p<3;p++) { for(int q=0;q<3;q++) { System.out.println(c[p][q]); } } ] //tis will give u the output but u neeed to enter n dats the limit which in this case is 11........... |
|
Sponsored content
| Subject: Re: write a program | |
| |
|