RECTANGLE

Description:

Write a C++ Program to calculate the area and perimeter of rectangles using concept of inheritance. Test Case 1 Input (stdin) 5 4 3 2 Expected Output 20 10 Test Case 2 Input (stdin) 5 10 4 6 Expected Output 50 20

Program :

import java.io.*;

import java.util.Scanner;

public class TestClass {

 

    public static void main (String[] args){

      Scanner in =new Scanner(System.in);

      int l,b,h,w,p,a,c;

      l=in.nextInt();

      b=in.nextInt();

      h=in.nextInt();

      w=in.nextInt();

      a=l*b;

      c=h+w;

      p=2*c;

      System.out.println(a);

      System.out.println(p);

    }

}