314-18 guruh talabasi Abduvohid Ergashev
9-variant
Integral hisoblashning trapetsiya usuli
Formulasi:
Funksiya : y = sin(x)/2
Dastur kodi:
package integral;
import java.util.Scanner;
public class integral {
public static void main(String[] args) {
System.out.println("y=sin(x)/2 funksiyaning a va b oraliqdagi integralini trapetsiyalar usulida hisoblash: ");
System.out.print("a=");
Scanner in = new Scanner(System.in);
int a = in.nextInt();
System.out.print("b=");
int b = in.nextInt();
integral(a,b);
}
static void integral(int a, int b){
double y;
y = (b-a)*(funksiya(a)+funksiya(b))/2;
System.out.println(String.format("Funksiyaning %d va %d oraliqdagi integrali: \n%f",a,b,y));
}
static double funksiya(int x){
return Math.sin(x)/2;
}
}
Dastur natijasi:
Do'stlaringiz bilan baham: |