1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Yuliya22 [10]
3 years ago
5

Write a test program that creates two Rectangle objects—one with width 4 and height 40 and the other with width 3.5 and height 3

5.7. Display the width, height, area, and perimeter of each rectangle in this order.
Computers and Technology
1 answer:
BARSIC [14]3 years ago
5 0

Answer:

public class Rectangle {

   private double width;

   private double heigth;

   public Rectangle(double width, double heigth) {

       this.width = width;

       this.heigth = heigth;

   }

   public double getWidth() {

       return width;

   }

   public void setWidth(double width) {

       this.width = width;

   }

   public double getHeigth() {

       return heigth;

   }

   public void setHeigth(double heigth) {

       this.heigth = heigth;

   }

   public double perimeter(double width, double heigth){

       double peri = 2*(width+heigth);

       return peri;

   }

   public double area(double width, double heigth){

       double area = width*heigth;

       return  area;

   }

}

class RectangleTest{

   public static void main(String[] args) {

       //Creating two Rectangle objects

       Rectangle rectangle1 = new Rectangle(4,40);

       Rectangle rectangle2 = new Rectangle(3.5, 35.7);

       //Calling methods on the first Rectangel objects

       System.out.println("The Height of Rectangle 1 is: "+rectangle1.getHeigth());

       System.out.println("The Width of Rectangle 1 is: "+rectangle1.getWidth());

       System.out.println("The Perimeter of Rectangle 1 is: "+rectangle1.perimeter(4,40));

       System.out.println("The Area of Rectangle 1 is: "+rectangle1.area(4,40));

       // Second Rectangle object

       System.out.println("The Height of Rectangle 2 is: "+rectangle2.getHeigth());

       System.out.println("The Width of Rectangle 2 is: "+rectangle2.getWidth());

       System.out.println("The Perimeter of Rectangle 2 is: "+rectangle2.perimeter(4,40));

       System.out.println("The Area of Rectangle 2 is: "+rectangle2.area(4,40));

   }

}

Explanation:

  • Firstly A Rectangle class is created with two fields for width and heigth, a constructor and getters and setters the class also has methods for finding area and perimeters
  • Then a RectangleTest class containing a main method is created and two Rectangle objects are created (Follow teh comments in the code)
  • Methods to get height, width, area and perimeter are called on each rectangle object to print the appropriate value
You might be interested in
Which of the following combinations would constitute a vertical merger?
Ksenya-84 [330]

Answer:

D

Explanation:

A vertical merger is when two or more companies merge and are involved at different stages in the supply chain process for a common good or service.  The merger is purposed to increase synchronism, gain more control of the supply chain process, and increase business. Also, it often results in reduced costs and increased productivity and efficiency.

A good example of a vertical merger is a auto manufacturer purchasing a tire company.  A vertical merger  of this sort reduces the cost of tires for the automaker and creates the possibility for expansion of its business by allowing it to supply tires to competing automakers.

6 0
4 years ago
In the late 1990s, Microsoft was sued for "tying" its Internet browser, Internet Explorer, to its operating system. A seller for
LekaFEV [45]

Answer:

Section 3 of the Clayton act.

Explanation:

Section 3 of the Clayton act 15 U.S.C.S § 14, makes illegal some kind of distribution practice that facilitates monopolistic arrangement that is section 3 of the Clayton act makes it illegal to enter into tying arrangement, exclusive dealing contracts or requirement contracts if such contracts tends to lessen competition. Where customer is required to pay for an undesired product in order to obtain a desired product.

3 0
3 years ago
Explain what an IM is, and what is the technology shown in the accompanying figure
sergiy2304 [10]

Answer: Instant Message

Explanation:

7 0
3 years ago
Read 2 more answers
Smith wants to get a job in network systems. Which major should he choose to give him the best chance of getting a job?
Sever21 [200]
<span>computer engineering</span>
5 0
4 years ago
Read 2 more answers
What are the differences, physically and logically, between the two printing configurations: Network-attached Printing and Netwo
evablogger [386]

Answer:

They are essentially the same physically. Logically, the print jobs are handled differently.

Explanation:

7 0
4 years ago
Other questions:
  • By using colocated, replicated hardware and software, cloud solution providers reduce many threats to IT resources.
    5·1 answer
  • Which of the following refers to the data analysis software and interactive software that allow managers to conduct analyses and
    6·1 answer
  • What is the process called that occurs when you start up your computer? A Download B Restore C Boot D Copy
    12·2 answers
  • The writers that most likely influenced our Founding Fathers were _____. Select all that apply. Swift and Bacon Marlowe and Kant
    14·2 answers
  • Which of the following is a separate summary worksheet in the same workbook?
    14·1 answer
  • Your one output statement should occupy two lines in your program
    13·1 answer
  • I AM GIVING BRAINLIEST!!!!!!! PLEASE HELP !!!!!!!!
    7·2 answers
  • How many different textile items would you find at a festival? (please list 5 items)
    7·1 answer
  • Which type of software is created on user dimension​
    5·1 answer
  • Write a short note on Ms - Excel...​..
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!