Abstract Class

/*
Write a Java Program to create an abstract class named Shape that contains two integers and an empty method named print Area(). Provide three classes named Rectangle, Triangle and Circle such that each one of the classes extends the class Shape. Each one of the classes contains only the method print Area () that prints the area of the given shape.
*/
// Abstract class
import java.util.*;
abstract class Shape
{
     int x, y;
     abstract public void printArea();
}
class Rectangle extends Shape
{
     Scanner s = new Scanner(System.in);
     void fnRead()
     {
          System.out.println(“Rectangle : “);
          System.out.print(“Enter length : “);
          x = s.nextInt();
          System.out.print(“Enter breadth : “);
          y = s.nextInt();
     }
     public void printArea()
     {
          System.out.println(“Area of rectangle = ” + (double)(x*y));
     }
}
class Triangle extends Shape
{
     Scanner s = new Scanner(System.in);
     void fnRead()
     {
          System.out.println(“Triangle : “);
          System.out.print(“Enter base : “);
          x = s.nextInt();
          System.out.print(“Enter height: “);
          y = s.nextInt();
     }
     public void printArea()
     {
          System.out.println(“Area of triangle = ” + ((double)(1.0/2.0)*x*y));
     }
}
class Circle extends Shape
{
     Scanner s = new Scanner(System.in);
     void fnRead()
     {
          System.out.println(“Circle : “);
          System.out.print(“Enter radius : “);
          x = s.nextInt();
     }
     public void printArea()
     {
          double pi = 3.142;
          System.out.println(“Area of circle = ” + (double)(pi*x*x));
     }
}
public class AreaShapes
{
     public static void main(String as[])
     {
          Rectangle r = new Rectangle();
          Triangle t = new Triangle();
          Circle c = new Circle();
          r.fnRead();
          r.printArea();
          t.fnRead();
          t.printArea();
          c.fnRead();
          c.printArea();
     }
}