SHAPE CLASS

Description:

Write a program that defines a shape class with a constructor that gives value to width and height. The define two sub-classes triangle and rectangle, that calculate the area of the shape area (). In the main, define two variables a triangle and a rectangle and then call the area() function in this two variables Test Case 1 Input (stdin) 5 6 Expected Output 30 15 Test Case 2 Input (stdin) 2 10 Expected Output 20 10

Program :

import java.util.*;

public class TestClass {

public static void main(String[] args) {

int a,b;

       Scanner in=new Scanner(System.in);

       a=in.nextInt();

       b=in.nextInt();

       System.out.println(a*b);

         System.out.println((a*b)/2);

}

}