Skip to content

fix: Adjust errors in AreaRect class #200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
32 changes: 18 additions & 14 deletions Programs/areaRect.java → Programs/AreaRect.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
}
}
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down