Lab#2 Journal Waleed Khalid [OOP]
Lab#2 Journal Waleed Khalid [OOP]
March 2, 2025
LAB TASK # 1: Create a Rectangle Class with
• Attributes – length and width
• Constructor – to initialize the attributes
• Methods – calArea(length, width), calPerimeter(length, width)
• calArea(length, width) – Calculate the area of the rectangle and
display it
• calPerimeter(length, width) – Calculate the perimeter of the rectangle
and
display it
• Write main method to check the functionality of the class
Program:
public class Rectangle {
private double length;
private double width;
Program:
public class Employee {
private String name;
private double salary;
private int hoursWorked;
Program:
public class Account {
private String name;
private double balance;