Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please type the code in Java and have a screenshot of the output attached. Lab-04-01 The following program Lab4.0 demonstrates structural programming solution to calculate
Please type the code in Java and have a screenshot of the output attached.
Lab-04-01 The following program Lab4.0 demonstrates structural programming solution to calculate Rectangle area. This program accept the length and width variables as arguments of method getArea(20,30) and return the area of Rectangle Your job is to write an object oriented program with following definitions: 1. Name the class Rectangle, (look blow the Hint line), public class Rectangle. 2. Add a data member name width of type double private. 3. Add a data member named Length of type double private. Add a void method display(), to print to standard output the fields Length, Width, and area of Rectangle. 5. Demo program to test your program 4. 1. 4. A. 7/Lab4.0 package rectangle; public class Rectangle { public static void main(String[] args) { double area=getArea (20,30); System.out.println(area); } static double getArea (double 1, double w) { return (1*w); } } Hint ---Look at the video clip attached to assignment page public class Rectangle { private double length; private double width; void setProperty (double len, double wed) (...3 lines) double getArea() {...3 lines } public void display() { System.out.println("W="+ width+ "L="+length+" Area="+getArea()); 1 )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