class Paralelogram{ double length; double breadth; void area(){ System.out.print("The area is: "); System.out.println(length*breadth); } } public class Main{ public static void main (String args[]){ Paralelogram para1 = new Paralelogram(); Paralelogram para2 = new Paralelogram(); double area; para1.length=8.5; para1.breadth=7.5; para2.length=5; para2.breadth=3; para1.area(); para2.area(); } }
The Output is Given Below:
The area is: 63.75
The area is: 15.0
0 comments:
Post a Comment