diff --git a/Programs/areaRect.java b/Programs/AreaRect.java similarity index 56% rename from Programs/areaRect.java rename to Programs/AreaRect.java index ac2b154..2121a5f 100644 --- a/Programs/areaRect.java +++ b/Programs/AreaRect.java @@ -1,22 +1,14 @@ // Program to calculate the area of rectangle using return values - -package area; -class Rectangle { - public int l, b; - public void getData(int m, int n) { - l = m; - b = n; - } - public int calcArea() { - int area = l * b; - return area; - } -} + public class AreaRect { public static void main(String[] args) { + + AreaRect areaRect = new AreaRect(); + // TODO Auto-generated method stub int a1, a2; - Rectangle r1 = new Rectangle(); - Rectangle r2 = new Rectangle(); + Rectangle r1 = areaRect.new Rectangle(); + Rectangle r2 = areaRect.new Rectangle(); r1.l = 10; r1.b = 15; a1 = r1.l * r1.b; @@ -25,4 +17,16 @@ public static void main(String[] args) { System.out.println("The area of first rectangle = " + a1); System.out.println("The area of second rectangle = " + a2); } + + public class Rectangle { + public int l, b; + public void getData(int m, int n) { + l = m; + b = n; + } + public int calcArea() { + int area = l * b; + return area; + } + } } \ No newline at end of file diff --git a/README.md b/README.md index cb3d676..1037c85 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ It is very easy to contribute, you may follow these steps - ## Programs: 1. [Abstract Class](https://github.com/PrajaktaSathe/Java/blob/main/Programs/abstractClass.java) - Program to demonstrate abstract classes in Java -2. [Rectangle Area](https://github.com/PrajaktaSathe/Java/blob/main/Programs/areaRect.java) - Calculates area of a rectangle +2. [Rectangle Area](https://github.com/PrajaktaSathe/Java/blob/main/Programs/AreaRect.java) - Calculates area of a rectangle 3. [Arithmetic exceptions](https://github.com/PrajaktaSathe/Java/blob/main/Programs/arithExceptions.java) - Program to show Arithmetic Exception Error handling 4. [Array Lists](https://github.com/PrajaktaSathe/Java/blob/main/Programs/arrayLists.java) - Program to show list of strings in java 5. [Array Out Of Bounds](https://github.com/PrajaktaSathe/Java/blob/main/Programs/arrayOutOfBounds.java) - Program to show ArrayOutOfBoundsException Error handling