Implement a class named Rectangle to represent a rectangle using Java 1) Class name: Rectangle; accessibility: public 2) The class contains: Two private double data fields named width and height that specify the width and height of the rectangle. 3) A no-arg constructor that creates a default rectangle: data fields are 1 for both width and height. 4) A constructor that creates a rectangle with the specified width and height. 5) A public method named setWidth that sets the value of width 6) A public method named getWidth that returns the value of width 7) A public method named setHeight that sets the value of height 8) A public method named getHeight that returns the value of height 9) A public method named getPerimeter() that returns the perimeter. 10) A public method named getArea() that returns the area of this rectangle. 11) Draw the UML class diagram 12) Write a test file that creates two Rectangle objects: one with width 4 and height 40 and the other with width 3.5 and height 35.9. Display the width, height, area and perimeter of each rectangle in this order

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter4: More Object Concepts
Section: Chapter Questions
Problem 11PE
icon
Related questions
Question
Implement a class named Rectangle to represent a rectangle using Java 1) Class name: Rectangle; accessibility: public 2) The class contains: Two private double data fields named width and height that specify the width and height of the rectangle. 3) A no-arg constructor that creates a default rectangle: data fields are 1 for both width and height. 4) A constructor that creates a rectangle with the specified width and height. 5) A public method named setWidth that sets the value of width 6) A public method named getWidth that returns the value of width 7) A public method named setHeight that sets the value of height 8) A public method named getHeight that returns the value of height 9) A public method named getPerimeter() that returns the perimeter. 10) A public method named getArea() that returns the area of this rectangle. 11) Draw the UML class diagram 12) Write a test file that creates two Rectangle objects: one with width 4 and height 40 and the other with width 3.5 and height 35.9. Display the width, height, area and perimeter of each rectangle in this order
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
void method
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage