Question 1


1 ) Write a Java program to calculate the area of a rectangle with a length of 15 cm and a breadth of 10 cm.

Program: 

public class RectangleArea {
    public static void main(String[] args) {
        // Declare and initialize the length and breadth variables
        int length = 15;
        int breadth = 10;
        // Calculate the area of the rectangle
        int area = length * breadth;
        // Print the result
        System.out.println("The area of the rectangle is: " + area + " cm²");
    }
}

Output:

The area of the rectangle is: 150 cm²

Question 2