Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Visual C# And Databases

Authors: Philip Conrod, Lou Tylee

16th Edition

1951077083, 978-1951077082

Students also viewed these Databases questions