// 12_MathExample.java - שימוש במחלקה Math

public class MathExample {
    public static void main(String[] args) {
        // קבועים
        System.out.println("PI = " + Math.PI);
        System.out.println("E = " + Math.E);

        // פעולות בסיסיות
        System.out.println("\nפעולות בסיסיות:");
        System.out.println("abs(-5) = " + Math.abs(-5));
        System.out.println("max(10, 20) = " + Math.max(10, 20));
        System.out.println("min(10, 20) = " + Math.min(10, 20));

        // חזקה ושורש
        System.out.println("\nחזקות ושורשים:");
        System.out.println("2^10 = " + Math.pow(2, 10));
        System.out.println("sqrt(144) = " + Math.sqrt(144));
        System.out.println("cbrt(27) = " + Math.cbrt(27));

        // עיגול
        System.out.println("\nעיגול:");
        System.out.println("round(4.4) = " + Math.round(4.4));
        System.out.println("round(4.5) = " + Math.round(4.5));
        System.out.println("ceil(4.1) = " + Math.ceil(4.1));
        System.out.println("floor(4.9) = " + Math.floor(4.9));

        // טריגונומטריה
        System.out.println("\nטריגונומטריה:");
        System.out.println("sin(90°) = " + Math.sin(Math.toRadians(90)));
        System.out.println("cos(0°) = " + Math.cos(0));
        System.out.println("tan(45°) = " + Math.tan(Math.toRadians(45)));

        // דוגמה: היפוטנוזה של משולש ישר זווית
        double a = 3;
        double b = 4;
        double c = Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2));
        System.out.println("\nהיפוטנוזה (3, 4) = " + c);

        // עיגול למספר ספרות אחרי הנקודה
        double value = 3.14159265;
        double rounded = Math.round(value * 100.0) / 100.0;
        System.out.println("3.14159265 מעוגל ל-2 ספרות: " + rounded);
    }
}
