0% found this document useful (0 votes)
20 views3 pages

Java Ia

The document defines an abstract class called Anukrati that contains an abstract method called Area_anukrati. It then defines three subclasses called Rectangle_AKT, Circle_AKT, and Triangle_AKT that extend Anukrati and implement the Area_anukrati method to calculate and output the area of a rectangle, circle, and triangle respectively by taking user input for dimensions. The main method creates instances of each subclass and calls their Area_anukrati method.

Uploaded by

Shivam Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views3 pages

Java Ia

The document defines an abstract class called Anukrati that contains an abstract method called Area_anukrati. It then defines three subclasses called Rectangle_AKT, Circle_AKT, and Triangle_AKT that extend Anukrati and implement the Area_anukrati method to calculate and output the area of a rectangle, circle, and triangle respectively by taking user input for dimensions. The main method creates instances of each subclass and calls their Area_anukrati method.

Uploaded by

Shivam Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

IA

import java.util.Scanner;

import java.io.*;

abstract class Anukrati

public abstract void Area_anukrati();

class Rectangle_AKT extends Anukrati

public void Area_anukrati()

int l,b;

Scanner s=new Scanner(System.in);

System.out.println("Enter the length and breadth of rectangle");

l=s.nextInt();

b=s.nextInt();

System.out.println("area="+ l*b);

class Circle_AKT extends Anukrati

public void Area_anukrati()

int r;

Scanner s=new Scanner(System.in);

System.out.println("Enter the radius of circle");

r=s.nextInt();
System.out.println("area="+ 3.14*r*r);

class Triangle_AKT extends Anukrati

public void Area_anukrati()

int ba,h;

Scanner s=new Scanner(System.in);

System.out.println("Enter the base and height of triangle");

ba=s.nextInt();

h=s.nextInt();

System.out.println("area="+ (ba*h)/2);

public class Main

public static void main (String[] args)

Rectangle_AKT s1= new Rectangle_AKT();

s1.Area_anukrati();

Circle_AKT s2= new Circle_AKT();

s2.Area_anukrati();

Triangle_AKT s3= new Triangle_AKT();

s3.Area_anukrati();

You might also like