1-Topshiriq
2
import java.util.Scanner;
public class loborotoria_1_1_2 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
double a, b, c, x;
System.out.println("O'zgaruvchilarni kiritng: ");
a = scanner.nextDouble();
b = scanner.nextDouble();
c = scanner.nextDouble();
x = scanner.nextDouble();
double Q = 0;
if (a < 0) {
Q = (Math.pow(Math.sin(a * x), 2) + Math.pow(Math.cos(a * x * x), 3)) / (Math.pow((a + b), 2) + c);
} else if (Math.pow(a,2) >= Math.pow(b,3)) {
Q = (Math.sqrt(a * a + b * b * b) + 2 * a * c) / (Math.pow(Math.sin(a),2)+b*x*x);
}else System.out.println("Yechimga ega emas");
System.out.println(Q);
}
}
2-Topshiriq
2. Bo‘sh bo'lmagan va oxiri 0 soni bilan tugaydigan musbat butun sonlar ketma-ketligi berilgan (0 soni ketma-ketlikka kirmaydi va uning tugaganligini bildiradi). Ketma-ketlikning o‘rta geometrik qiymati hisoblansin
import java.util.Scanner;
public class loborotoria_1_2_2 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
double product = 1;
int length = 0;
double num = 1;
while (true) {
System.out.print("Butun son kiriting: ");
num = scanner.nextInt();
if (num != 0){
product *= num;
length ++;
}
else break;
}
// O'rta geometrik qiymat hisoblanadi
double geometricMean = Math.pow(product, 1.0 / length);
System.out.println("Ketma-ketlikning o'rta geometrik qiymati: " + geometricMean);
}
}
Dostları ilə paylaş: |