Question: import javax.swing.JOptionPane; public class Driver { public static void main(String[] args) { Rectangle tennisCourt = null; double width; double length; width = Double.parseDouble(JOptionPane.showInputDialog(null, Enter Length:

import javax.swing.JOptionPane;

public class Driver {

public static void main(String[] args) { Rectangle tennisCourt = null; double width; double length; width = Double.parseDouble(JOptionPane.showInputDialog(null, "Enter Length: ")); length = Double.parseDouble(JOptionPane.showInputDialog(null, "Enter Width: " )); tennisCourt.setLength(length); tennisCourt.setWidth(width); JOptionPane.showMessageDialog(null, "The area of a rectangle with a length " + "of " + getLength() + " and a width of " + getWidth() + " is " + getArea() ); }

}

public class Rectangle { private double width; private double length; public Rectangle() { width = 0.0; length = 0.0; } public Rectangle(double newWidth, double newLength) { width = newWidth; length = newLength; } public void setWidth(double newWidth) { width = newWidth; }

public void setLength(double newLength) { length = newLength; }

public double getWidth() { return width; } public double getLength() { return length; }

public double getArea() { return (length * width); } }

use the get member functions to display the area?

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!