// Basics.java — variables, primitive types, var and strings.
public class Basics {

    public static void main(String[] args) {
        // Primitive types hold simple values
        int quantity = 24;
        double price = 8.50;
        boolean inStock = true;
        char grade = 'A';
        long bigNumber = 9_000_000_000L;   // underscores make big numbers readable

        // Arithmetic
        double total = quantity * price;
        System.out.println("Total: " + total);            // Total: 204.0
        System.out.println("10 / 3 = " + (10 / 3));       // integer division: 3
        System.out.println("10 / 3.0 = " + (10 / 3.0));   // 3.3333333333333335
        System.out.println("10 % 3 = " + (10 % 3));       // remainder: 1

        // var lets the compiler work out the type (Java 10+)
        var customer = "Acme Ltd";        // String
        var lines = 3;                    // int

        // Strings are objects with lots of useful methods
        String order = "  po-4471  ";
        String clean = order.trim().toUpperCase();
        System.out.println(clean);                         // PO-4471
        System.out.println(clean.startsWith("PO"));        // true
        System.out.println(clean.replace("-", "_"));       // PO_4471
        System.out.println(customer.length() + " characters");

        // Formatting
        String summary = String.format("%s ordered %d lines worth %.2f", customer, lines, total);
        System.out.println(summary);

        // Text blocks (Java 15+) for multi-line strings
        String json = """
                {
                  "order": "PO-4471",
                  "inStock": true
                }
                """;
        System.out.print(json);

        // Comparing strings: use equals, not ==
        String a = "boomi";
        String b = new String("boomi");
        System.out.println(a.equals(b));   // true
        System.out.println(a == b);        // false — different objects

        System.out.println(grade + " " + bigNumber + " " + inStock);
    }
}
