Skip to content
This repository has been archived by the owner on Oct 7, 2023. It is now read-only.

Create WVKbSc.java #1593

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions OLyM8K/WVKbSc.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
public class WVKbSc {
private double width;
private double height;

// Constructor
public WVKbSc(double width, double height) {
this.width = width;
this.height = height;
}

// Method to calculate the area of the rectangle
public double calculateArea() {
return width * height;
}

// Method to calculate the perimeter of the rectangle
public double calculatePerimeter() {
return 2 * (width + height);
}

// Method to display information about the rectangle
public void displayInfo() {
System.out.println("Width: " + width);
System.out.println("Height: " + height);
System.out.println("Area: " + calculateArea());
System.out.println("Perimeter: " + calculatePerimeter());
}

public static void main(String[] args) {
// Create a Rectangle object with a specified width and height
WVKbSc rectangle = new WVKbSc(5.0, 7.0);

// Display information about the rectangle
rectangle.displayInfo();
}
}