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

Write a program with 4 methods, get two output execution runs of the program The

ID: 3642493 • Letter: W

Question

Write a program with 4 methods, get two output execution runs of the program
The program calls the following 4 methods, which have not been written. It is your job to write these 4 methods:
getLength - This method should ask the user to enter the rectangle's length, and then return that value as a double.
getWidth - This method should ask the user to enter the rectangles' width, and then return that value as a double.
getArea - This method should accept the rectangle's length and width as arguments, and return the rectangle's area as a double. The area is calculated by multiplying the length by the width.
displayData - This method should accept the rectangle's length, width, and area as arguments, and display them in an appropriate message on the screen.

Here is first run of program (program output in italics and user input in bold/italics ):

Enter the rectangle's length: 10
Enter the rectangle's width: 20
The length is 10.0, the width is 20.0 and the area is 200.0.

Here is second run of program:

Enter the rectangle's length: 12.5
Enter the rectangle's width: 9.5
The length is 12.5, the width is 9.5 and the area is 118.75.


Turn in FOR CREDIT:
1) Program listing
2) Program output showing TWO separate program executions /runs

Explanation / Answer

please rate - thanks

sample runs

import java.util.*;
    public class main
   {public static void main(String[] args)
      {Scanner in = new Scanner(System.in);
        double length,width,area;
        length=getLength(in);
        width=getWidth(in);
        area=getArea(length,width);
        displayData(length,width,area);
            }
public static double getLength(Scanner in)
    {double length;
    System.out.print("Enter the rectangle's length: ");
    length=in.nextDouble();
    return length;   
         }
public static double getWidth(Scanner in)
    {double width;
    System.out.print("Enter the rectangle's width: ");
    width=in.nextDouble();
    return width;   
         }
public static double getArea(double length, double width)
    {return length*width;
    }
public static void displayData(double length, double width,double area)
    {System.out.printf("The length is %.1f, the width is %.1f and the area is %.2f. ",length,width,area);
    }
       
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote