Professional Documents
Culture Documents
Oop 4TH Lab
Oop 4TH Lab
Program -
Shapearea file -
//Abstract class
Circle file -
int radius;
this.radius = r;}
System.out.println("Radius:- "+radius);
System.out.println("Area:- "+area);}
float p = 2*3.14f*radius;
System.out.println("Perimeter:- "+p);}
c.getarea();
c.getperimeter();}
Rectangle file -
{
this.length = l;
this.breadth = b;
System.out.println("Length:- "+length);
System.out.println("Breadth:- "+breadth);
System.out.println("Area:- "+area);
float p = 2*(length+breadth);
System.out.println("Perimeter:- "+p);
r.getarea();
r.getperimeter();
Square file -
int side;
public Square(int s)
this.side = s;
System.out.println("Side:- "+side);
System.out.println("Area:- "+area);
float p = 4*(side);
System.out.println("Perimeter:- "+p);
s.getarea();
s.getperimeter();
Output -
Radius:- 10
Area:- 314.0
Perimeter:- 62.800003
Length:- 10
Breadth:- 5
Area:- 50.0
Perimeter:- 30.0
Side:- 10
Area:- 100.0
Perimeter:- 40.0
PROGRAM - 14
Program -
Account file -
//abstract class
Savings file -
int balance;
public Savings(int s)
this.balance = s;
System.out.println("Deposit Successful!!" );
if(this.balance<100)
else
Current file -
int no_of_transaction;
public Current(int s)
this.no_of_transaction = s;
if(this.no_of_transaction<2)
else
System.out.println("Deposit Successful!!" );
}}
c.deposit();}
OUTPUT-
Balance is low :: 10
Deposit failed!!