Question
Java: If you look at the attached program you will see calls to methods from the main method which do not yet exist! Write and
Java:
If you look at the attached program you will see calls to methods from the main method which do not yet exist! Write and add those methods to your program. For example getLength() is a method that takes NO parameters, so what it should do is prompt the user running the program to enter a value for the length of the desired rectangle (getWidth() is the same as getLength() except it's requesting the width of the rectangle. getArea(length, width) on the other hand does require parameter values passed to it and the method simply calculates the area of the rectangle. displayData(length, width, area) requires 3 parameter values and all it should do is output the length of the rectangle, width of the rectangle, and the area of the rectangle (please label the output so the user knows what the numbers being displayed represent).
Methods:
getLength()
getWidth()
getArea(length, width)
displayData(length, width, area)
It will display this data either using the console or in a JOptionPane message dialog
/** You must complete this program so it calculates and displays the area of a rectangle. */ // Insert any necessary import statements here. public class AreaRectangle { public static void main(String[] args) { double length, // The rectangle's length width, // The rectangle's width area; // The rectangle's area // Get the rectangle's length from the user. length = getLength(); // Get the rectangle's width from the user. width = getWidth(); // Get the rectangle's area. area = getArea(length, width); // Display the rectangle data. displayData(length, width, area); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started