JustPaste
HomeCategoriesAboutDonateContactTerms of UsePrivacy Policy
JustPaste

Free online notepad — write and share instantly

Navigate

  • Home
  • Timeline
  • Categories

Info

  • About
  • Donate
  • Contact

Legal

  • Terms of Use
  • Privacy Policy

© 2026 JustPaste.app. All rights reserved.

Made with ♥ by JustPaste

Untitled Page | JustPaste.app
1 day ago6 views
👨‍💻Programming

Untitled Page

import java.util.*;

abstract class Shape {
int length, breadth, radius;

Scanner input = new Scanner(System.in);

abstract void printArea();

}

class Rectangle extends Shape {
void printArea() {
System.out.println("*** Finding the Area of Rectangle ***"); System.out.print("Enter length and breadth: ");
length = input.nextInt(); breadth = input.nextInt();
System.out.println("The area of Rectangle is: " + length * breadth);
}
}

class Triangle extends Shape {
void printArea() {
System.out.println("\n*** Finding the Area of Triangle "); System.out.print("Enter Base And Height: ");
length = input.nextInt(); breadth = input.nextInt();
System.out.println("The area of Triangle is: " + (length * breadth)/2);
}
}
class Cricle extends Shape {
void printArea() {
System.out.println("\n Finding the Area of Cricle ***"); System.out.print("Enter Radius: ");
radius = input.nextInt();
System.out.println("The area of Cricle is: " + 3.14f * radius * radius);
}
}
public class Main {
public static void main(String[] args) { Rectangle rec = new Rectangle(); rec.printArea();

Triangle tri = new Triangle(); tri.printArea();

Cricle cri = new Cricle(); cri.printArea();
}
}
← Back to timeline