Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Based off the instructions in Chapter 6, Create a rectangle class in this file that has: 2 double variables for length and width(6.2) Sets and

Based off the instructions in Chapter 6, Create a rectangle class in this file that has: 2 double variables for length and width(6.2) Sets and Gets statements for both variables (6.2) A method that returns the Area of the Rectangle(6.2) Create a constructor for the Rectangle class that takes 2 arguments (length & width) Create a No-Arg constructor for the Rectangle class A main method and code to test the class has been already included in the bottom half of the provided code. Do not change it or the class code may not work:

public class Rectangle {

// enter required code here

// ***** The code below this line is for testing ***** // **********Do not change anything below this line. ***** public static void main(String[] args) { // Create a scanner object to collect input Scanner input = new Scanner(System.in); Rectangle rectangle = new Rectangle(); // create a nwe rectangle object System.out.print("Please enter the width of the room: "); rectangle.setWidth(input.nextDouble()); // collect the width as a double System.out.print("Please enter the length of the room: "); rectangle.setLength(input.nextDouble());// collect the length as a double // Display the output of the second rectangle object. System.out.printf("For a room %.2f by %.2f the area is %.2f ", rectangle.getWidth(),rectangle.getLength(),rectangle.getArea()); } } // End Rectangle Class

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

Students also viewed these Databases questions

Question

3. Describe the communicative power of group affiliations

Answered: 1 week ago