Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package dip107;
- import java.util.Scanner;
- public class Ld2_02_191RDC038
- {
- public static void main(String[] args)
- {
- Scanner sc = new Scanner(System.in);
- float x=0;
- double res;
- int i=1;
- double a=1,s=0;
- float k=-1;
- int j=2;
- System.out.println("2.var");
- System.out.println("191RDC038 Niks Veinbergs 1");
- System.out.println("181REB393 Edvards Siliņš 2");
- System.out.println("Vertiba x=");
- if (sc.hasNextFloat())
- {
- x = sc.nextFloat();
- }
- System.out.println("result:");
- if(x>=-2&&x<=-1)
- { while(Math.abs(a) > 0.001)
- {
- a=k*Math.pow(1+x,j)/i;
- s=a+s;
- i=i+1;
- j=j+2;
- k=-k;
- }
- res=Math.log(1/(2+2*x+x*x));
- System.out.printf("function=%.4f",res);
- System.out.printf("\nsumma=%.4f",s);
- }
- else
- {
- System.out.println("error");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement