Wednesday, October 23, 2019

Area and Perimeter of Rectangle

 

Question

You need to read two side values S1 and S2 from the user and calculate the area & perimeter of the rectangle using their side values and print the same.

Program

package area;
import java.util.Scanner;

public class Area
{
    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);
        long s1 = in.nextLong();
        long s2 = in.nextLong();
        //long area = s1 * s2;
        //long perimeter = 2 * (s1 + s2);
        System.out.println("Area " + (s1 * s2));
        System.out.println("Perimeter " + (2*(s1 + s2)));
    }
   
}

Video explanation



1 comment: