Course Solutions Uncategorized (Solved) : Find Correct Errors Following Java Program Class Rectangle Private Int Height 1 Private In Q35182967 . . . .

(Solved) : Find Correct Errors Following Java Program Class Rectangle Private Int Height 1 Private In Q35182967 . . . .

 

//Find and correct all the errors in the following Javaprogram.

class Rectangle {
private int height = 1;
private int width = 1;
  
public Rectangle(int height, int width) {
height = this.height;
width = this.width;
}
  
public void doubleHeight() {
height += 2;
}
  
public void doubleWidth() {
width *= 2;
}
  
public boolean isSquare() {
return height = width;
}
  
public void draw() {
for (int row = 0; row < width; row++) {
for (int col = 0; col < height; col++) {
System.out.println(“X”);
}
System.out.println();
}
}
}

class Driver {
public static void main(String[] args) {
Rectangle a = new Rectangle(3, 6);
Rectangle b = new Rectangle(5, 3);
  
a.doubleHeight;
b.doubleWidth;
  
if a.isSquare {
System.out.println(“First Rectangle is a square.”)
} else {
System.out.println(“First Rectangle is not a square.”)
}
a.draw();

if b.isSquare {
System.out.println(“Second Rectangle is

OR

PayPal Gateway not configured

OR

PayPal Gateway not configured

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post