Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

n Not JAVA e: Rectangle Area-Complete the Program using the starter code is give

ID: 3750749 • Letter: N

Question

n Not JAVA e: Rectangle Area-Complete the Program using the starter code is given r source code given below contains partially written program named AreaRectangle Your job is to complete the program organizing it. When you complete and run the program it asks the user to enter the width and length of a rectangle, and then display the rectangle's area. by write the methods and import javax.swing.JOptionPane; Programming Challenge , Rectangle Area public class AreaRectangle public static void main(StringIl args) double lengthiThe rectangle's length double width; double area; // The rectangle's width // The rectangle's area // Get the rectangle's length from the user. length = getLength(); // Get the rectangle's width from the user. width getWidth0 // Get the rectangle's area. area getArea (length, width): // Display the rectangle data. displayData (length, width, area); System.exit (0): These are the methods and their purpose. getlength-This method should ask the user to enter the rectangle's len and then return that value as a double. getWidth-This method should ask the user to enter the rectangle's width then return that value as a double , and getArea aisplay Duta

Explanation / Answer

import javax.swing.*; public class AreaRectangle { public static void main(String[] args) { double length; double width; double area; length = getLength(); width = getWidth(); area = getArea(length, width); displayDate(length, width, area); System.exit(0); } static double getLength() { return Double.parseDouble(JOptionPane.showInputDialog("Enter length of the rectangle")); } static double getWidth() { return Double.parseDouble(JOptionPane.showInputDialog("Enter width of the rectangle")); } static double getArea(double length, double width) { return length * width; } static void displayDate(double length, double width, double area) { JOptionPane.showMessageDialog(null, "Area of rectangle with length " + length + " and width " + width + " is " + area); } }