Question: Creating a Programmer-Defined Class in Java: Hello, I have the program I believe almost complete, though, I am getting errors about the absence of an

Creating a Programmer-Defined Class in Java:

Hello, I have the program I believe almost complete, though, I am getting errors about the absence of an identifier for my System.out.println Lines. any idea what i'm missing?

First chunk of code is my class file and second is my program:

class Rectangle { // Length of this rectangle. private double rectangleLength; // Width of this rectangle. private double rectangleWidth;

// Write set methods here. public void setRectangleLength(double length) { rectangleLength = length; return; } public void setRectangleWidth(double width) { rectangleWidth = width; return; }

// Write get methods here. public double getRectangleLength() { return rectangleLength; } public double getRectangleWidth() { return rectangleWidth; } // Write the calculatePerimeter() and // calculateArea() methods here. private void calculateRectanglePerimeter() { rectanglePerimeter = (length * 2) + (width * 2); return; } private void calculateRectangleArea() { rectangleArea = length * width; return; } }

END OF CLASS FILE

PROGRAM:

// This program uses the programmer-defined Rectangle class.

public class MyRectangleClassProgram { public static void main(String args[]) { // Create rectangle1 and rectangle2 objects here. Rectangle rectangle1 = new Rectangle(); Rectangle rectangle2 = new Rectangle(); // Set the length of rectangle1 to 10.0 here. double LENGTH1 = 10.0; // Set the width of rectangle1 to 5.0 here. double WIDTH2 = 5.0;

// Print the area and perimeter of rectangle1 here. rectangle1.setRectangleWidth(WIDTH1); rectangle1.setRectangleLength(LENGTH1); System.out.println("The area and perimeter of rectangle1 is: " + getRectangleArea() + getRectanglePerimeter().;

// Set the length of rectangle2 to 7.0 here. double LENGTH2 = 7.0; // Set the width of rectangle2 to 3.0 here. double WIDTH2 = 3.0;

// Print the area and perimeter of rectangle2 here. rectangle2.setRectangleWidth(WIDTH2); rectangle2.setRectangleLength(LENGTH2); System.out.println("The area and perimeter of rectangle2 is: " + getRectangleArea() + getRectanglePerimeter().;

System.exit(0); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!