Tuesday, July 13, 2021

3. Write a program to print the area of a rectangle of sides 2 and 3 units respectively.

 public class Main {

      public static void main(String[] args) {

          int area = 2 * 3;

          System.out.println("The area is : " + area);

     }

}


NOTE:

  • Used multiplication(*) operator to multiply.
  • Didn't need Scanner class as input was already given.
  • Used int because there was no decimal in the input.

No comments:

Post a Comment