In: Computer Science
Q 1 - The surface area of a square or rectangle can be determined by multiplying the length by the breadth. In a method called GetArea(), write a Java program to determine the surface area of a given square or rectangle. Assume the measurements will be in metres. The program should prompt the user for length and breadth values. [15]
Input
None
Output
Given a rectangle with length 20 metres and breadth 15 metres, the
output would be: 300 square metres

import java.util.Scanner;
public class area {
   public static void main(String[] args) {
       Scanner in=new
Scanner(System.in);
       //user input
       System.out.println("Enter length:
");
       double
length=in.nextDouble();
      
       System.out.println("Enter width:
");
       double width=in.nextDouble();
       //print area
       System.out.println("Surface area
is: "+GetArea(length,width)+" square meter");
   }
   //method
   public static double GetArea(double length,double
width)
   {
       return length*width;//return
area
   }
}