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
max2010maxim [7]
3 years ago
12

Implement a class Rectangle. Provide a constructor to construct a rectangle with a given width and height, member functions get_

perimeter and get_area that compute the perimeter and area, and a member function void resize(double factor) that resizes the rectangle by multiplying the width and height by the given factor. (Page EX9-3).
Computers and Technology
1 answer:
lara [203]3 years ago
3 0
<h2>Answer:</h2>

//class declaration

public class Rectangle{

   

   //declare the instance variables - width and height

   double width;

   double height;

   

   

   //the <em>constructor</em>

  public Rectangle(double width, double height){

       

       //initialize the width of the rectangle

       this.width = width;

       

       //initialize the height of the rectangle

      this.height = height;

       

   }

   

   

   //method <em>get_perimeter</em> to compute the perimeter of the rectangle

   public double get_perimeter(){

       

       //compute the perimeter

       //by using the formula 2(width + height)

      double perimeter = 2*(this.width + this.height);

       

       //return the perimeter

       return perimeter;

   }

   

   //method <em>get_area</em> to compute the area of the rectangle

   public double get_area(){

       

       //compute the area

       //by multiplying the width and height of the rectangle

       double area = this.width * this.height;

       

       //return the area

      return area;

   }

   

   

   //method <em>resize</em> to resize the rectangle

   public void resize(double factor){

       

       //resize the width of the rectangle

       //by multiplying the width by the factor

       this.width = this.width * factor;

       

       //resize the height of the rectangle

       //by multiplying the height by the factor

      this.height = this.height * factor;

     

   }

   

}  //end of class declaration

<h2>Explanation:</h2>

The code above has been written in Java. In contains comments explaining every part of the program.

You might be interested in
Al these are benefits of computer literacy except
Harrizon [31]

Explanation:

  • Being computer literate supports entrepreneurship. ...
  • Communication. ...
  • Enhance your employment opportunities. ...
  • Address the gap in your knowledge. ...
  • Computers Reconstruct Business
8 0
3 years ago
I Promise Brainliest !!!!! Describe how the aperture size relates to the size of the lens opening.
sergey [27]

Answer:

As aperture increases in f-stop values, the lens closes. On the other hand, when aperture decreases in f-stop values, the lens opens.

Explanation:<u><em>plz give brainlist</em></u>

8 0
3 years ago
Read 2 more answers
What does the R in the acronym SMART stand for??
jeyben [28]
Depending on who you ask, it is either Realistic or Relevant. Organizations that can't choose sometimes use the acronym SMARRT.
7 0
4 years ago
The components of hardware include:
zlopas [31]

Answer:

A

Explanation:

Monitor, CPU, Disk Drives, Printer, Keyboard/mouse

5 0
3 years ago
Read 2 more answers
A ______ object is used for displaying the results of a question based on stored data.
LekaFEV [45]

Answer:

B. report

Explanation:

Report is used to show the result of data base quires or stored data contain useful data use in decision making and analysis.

It is also called a report generator, it is a part of database management system that is used to extract information from one or more files and present it in specific format.

4 0
3 years ago
Other questions:
  • When you need to cut new external threads on a bolt, what tool should you use?
    7·2 answers
  • To retrieve an outlook express e-mail header right-click the message, and then click ____ to open a dialog box showing general i
    7·1 answer
  • Which of the following is an Example of a technical (“hard”) skill
    6·2 answers
  • How can I make a video game?
    8·2 answers
  • A binary message consisting of four bits was sent to you by a friend. The message was supposed to be ABAB. Unfortunately, your f
    8·1 answer
  • To insure QoS of a network, an alternative to “prioritizing traffic” is to __________, which means holding back traffic from non
    8·1 answer
  • _________________ is the logical operator if either conditions is True, then the whole statement is TRUE.
    7·1 answer
  • What are the 3 rules of music<br><br> ps: there is no music subject so i had to put something else
    15·2 answers
  • Who used the term" software" first?
    8·2 answers
  • Assume you have written a method with the header num yourMethod(string name, num code). The method's type is ____ .
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!