15,998,382 members
Home / Discussions / Java

# Java

 Re: Realm EJB in Wildfly Richard MacCutchan31-Oct-20 1:07 Richard MacCutchan 31-Oct-20 1:07
 Re: Realm EJB in Wildfly Andy_Bell31-Oct-20 9:01 Andy_Bell 31-Oct-20 9:01
 Re: Realm EJB in Wildfly Andy_Bell11-Nov-20 23:46 Andy_Bell 11-Nov-20 23:46
 anyone know how a program would be written out for this Member 1497788728-Oct-20 9:53 Member 14977887 28-Oct-20 9:53
 Re: anyone know how a program would be written out for this Richard MacCutchan28-Oct-20 9:58 Richard MacCutchan 28-Oct-20 9:58
 Message Closed 28-Oct-20 10:11 Member 14977887 28-Oct-20 10:11
 Re: anyone know how a program would be written out for this Richard MacCutchan28-Oct-20 10:27 Richard MacCutchan 28-Oct-20 10:27
 The question is this-: Write a program using for loop that computes sinx and cosx by using the following power series- sinx=x-x^3/3!+x^5/5!-x^7/7!+.... cosx=1-x^2/2!+x^4/4!-x^6/6!+..... Note-(Here ! is used for factorial of that number and ^ for to the power) What I have tried is-: class sincos { void main(double x,int n) { int i,j,k,f; double sum=0.0; x=Math.toRadians(x); { for(i=1,j=1;i<=n;i=i+2,j++) { f=1; for(k=1;k<=i;k++) { f=f*i; } if(j%2==0) sum=sum-(Math.pow(x,i)/f); else sum=sum+(Math.pow(x,i)/f); } System.out.println("sin"+Math.toDegrees(x)+"="+sum); } for(i=0,j=1;i<=n;i=i+2,j++) { f=1; for(k=1;k<=i;k++) { f=f*i; } if(j%2==0) sum=sum-(Math.pow(x,i)/f); else sum=sum+(Math.pow(x,i)/f); } System.out.println("cos"+Math.toDegrees(x)+"="+sum); }} My problem is that I am not understanding that whether the source code I wrote is correct or not as the output is coming something else .I checked the code many times but still can't understand where the problem is. So can you check my source code and correct it according to the question.-- modified 5-Dec-20 21:01pm.
 Re: Using for loop create a bluej program for the question( https://1drv.ms/u/s! Ajrld_fzlfykhx8hc1sbkiufuc_p ) OriginalGriff26-Oct-20 21:05 OriginalGriff 26-Oct-20 21:05
 Re: Using for loop create a bluej program for the question( https://1drv.ms/u/s! Ajrld_fzlfykhx8hc1sbkiufuc_p ) Richard MacCutchan26-Oct-20 22:51 Richard MacCutchan 26-Oct-20 22:51
 Re: Using for loop create a bluej program for the question( https://1drv.ms/u/s! Ajrld_fzlfykhx8hc1sbkiufuc_p ) User 1494142127-Oct-20 5:16 User 14941421 27-Oct-20 5:16
 Re: Using for loop create a bluej program for the question( https://1drv.ms/u/s! Ajrld_fzlfykhx8hc1sbkiufuc_p ) Richard MacCutchan27-Oct-20 5:24 Richard MacCutchan 27-Oct-20 5:24
 Re: Using for loop create a bluej program for the question( https://1drv.ms/u/s! Ajrld_fzlfykhx8hc1sbkiufuc_p ) User 1494142127-Oct-20 5:39 User 14941421 27-Oct-20 5:39
 Re: Using for loop create a bluej program for the question( https://1drv.ms/u/s! Ajrld_fzlfykhx8hc1sbkiufuc_p ) User 1494142127-Oct-20 5:38 User 14941421 27-Oct-20 5:38
 Re: Using for loop create a bluej program for the question( https://1drv.ms/u/s! Ajrld_fzlfykhx8hc1sbkiufuc_p ) Richard MacCutchan27-Oct-20 5:42 Richard MacCutchan 27-Oct-20 5:42
 Re: Using for loop create a bluej program for the question( https://1drv.ms/u/s! Ajrld_fzlfykhx8hc1sbkiufuc_p ) User 1494142127-Oct-20 5:46 User 14941421 27-Oct-20 5:46
 Re: Using for loop create a bluej program for the question( https://1drv.ms/u/s! Ajrld_fzlfykhx8hc1sbkiufuc_p ) Richard MacCutchan27-Oct-20 5:56 Richard MacCutchan 27-Oct-20 5:56
 Re: Using for loop create a bluej program for the question( https://1drv.ms/u/s! Ajrld_fzlfykhx8hc1sbkiufuc_p ) Richard MacCutchan27-Oct-20 7:10 Richard MacCutchan 27-Oct-20 7:10
 Interview Question locking for Ans sureshkct26-Oct-20 4:52 sureshkct 26-Oct-20 4:52
 Re: Interview Question locking for Ans Richard MacCutchan26-Oct-20 5:34 Richard MacCutchan 26-Oct-20 5:34
 Re: Interview Question locking for Ans Dave Kreskowiak27-Oct-20 6:54 Dave Kreskowiak 27-Oct-20 6:54
 JAVA IF ELSE STATEMENT (HELP ME) tomatomoa24-Oct-20 7:45 tomatomoa 24-Oct-20 7:45
 Re: JAVA IF ELSE STATEMENT (HELP ME) Sandeep Mewara24-Oct-20 8:17 Sandeep Mewara 24-Oct-20 8:17
 Re: JAVA IF ELSE STATEMENT (HELP ME) tomatomoa3-Nov-20 2:18 tomatomoa 3-Nov-20 2:18
 Last Visit: 31-Dec-99 18:00     Last Update: 16-Sep-24 3:58 Refresh ᐊ Prev1...15161718192021222324 Next ᐅ

General    News    Suggestion    Question    Bug    Answer    Joke    Praise    Rant    Admin

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.