0% found this document useful (0 votes)
4 views

3-lab. Java

The document presents a Java program that calculates a value 'x' based on user inputs for 'p', 'a', and 'b'. It checks if 'x' falls within the specified interval [a, b] and outputs the result accordingly. The program utilizes mathematical functions such as tangent and absolute value.

Uploaded by

sarvarbek0125
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

3-lab. Java

The document presents a Java program that calculates a value 'x' based on user inputs for 'p', 'a', and 'b'. It checks if 'x' falls within the specified interval [a, b] and outputs the result accordingly. The program utilizes mathematical functions such as tangent and absolute value.

Uploaded by

sarvarbek0125
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

Sarvarbek Vaxobov

3-Laboratoriya ishi

Mavzu: Javada operatorlar va ifodalar bilan ishlash


Vazifalar: 26

import java.util.Scanner;

public class Main {


public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter value for p: ");
double p = scanner.nextDouble();
System.out.print("Enter value for a: ");
double a = scanner.nextDouble();
System.out.print("Enter value for b: ");
double b = scanner.nextDouble();

double x = (Math.tan(Math.sqrt(2)) + Math.abs(p)) / 2;

if (x >= a && x <= b) {


System.out.println("The root x = " + x + " belongs to the
interval [" + a + ", " + b + "].");
} else {
System.out.println("The root x = " + x + " does NOT belong to the
interval [" + a + ", " + b + "].");
}
scanner.close();
}
}

You might also like