How to determine the value of sinx series in nth term in java

Wednesday, March 18, 2009

import java.io.*; class angle { int p,q; void getData(int a, int b) { p=a; q=b; } float sin() { float y=p,t=1; for(int i=1;i { t=(-1)*p*p*t/(2*i*(2*i+1)); y=y+t*p; } return(y); } } class Sine { public static void main(String args[]) { DataInputStream in=new DataInputStream(System.in); int n=0,x=0; float y1; try { System.out.print("Enter the term:"); n=Integer.parseInt(in.readLine()); System.out.print("Enter the value of x:"); x=Integer.parseInt(in.readLine()); } catch(Exception e) {} angle series1= new angle(); series1.getData(x,n); y1=series1.sin(); System.out.println("y1=sinx="+y1); } }

0 comments:

Visitors

PlugIn.ws - Free Hit Counter, Web Site Statistics, Traffic Analysis

  © Blogger template Leaving by Ourblogtemplates.com 2008

Back to TOP