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]
2 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]2 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 is considered a modern method of communication?
Vika [28.1K]
The answer is C. Tablet, because that is the quickest, easiest, and most recent way of communication.
4 0
3 years ago
Read 2 more answers
Choosing a per_formatted presentation that already has a design and the slots is called choosing What​
Aloiza [94]
A template is a predesigned presentation you can use to create a new slide show quickly. Templates often include custom formatting and designs, so they can save you a lot of time and effort when starting a new project.
8 0
2 years ago
Which of the following is a technique for storing or copying log events to acentralized logging server?a. Syslogb. Write­once re
Neporo4naja [7]

Answer:A) Syslog

Explanation: Syslog is the log for the messaging in the computing field.It acts as a separator for the different task that is related to messaging. The task usually are storing of message, production of the message through software,analyzing message, reporting it etc.

Other options given in the question such as WORM storage is for the storage technology,UTM is for the management for the threat situation and firewall logging is related with log/tables for firewall.

Thus, the correct option is option (A).

5 0
3 years ago
A cell has an unlimited number of conditions for Conditional Formatting.<br> A.true<br> B.false
Mekhanik [1.2K]
I believe the answer is false.
I Hope this helps! :)
If you don't understand plz message me
If you do plz brainlest
Thank you!
7 0
3 years ago
Please help! i need to answer this soon!
natali 33 [55]

Answer:

1. a modem connects a computer to the internet  

4. a modem transmits digital signals over a telephone line

5. a dial-up modem communicates using a telephonic call​

All of three mentioned above.

Modem stands for modulator de-modulator, and it connects the computer to the internet. Its not the fastest, which is router. And the connection is established via the telephone line, through which the digital signals is being transmitted, And the type used is dial up communication.

Explanation:

The answer is self explanatory.

4 0
3 years ago
Other questions:
  • Describe how one device can send a bit to another device.
    9·1 answer
  • How many buttons does a gamecube controller have?
    7·1 answer
  • Sending a employee an email with important criticism represents a problem which communication process
    9·1 answer
  • In python:
    14·1 answer
  • To find your personal learning style you can
    5·2 answers
  • Relation between training and occupation with examples in points . Plz tell fast<br> ​
    5·1 answer
  • It is an array containing information such as headers, paths and script locations wherein it is created by the web server itself
    8·1 answer
  • Wow that funny a heck
    7·1 answer
  • What is an outcome in a game? Don't search google just give me an answer
    9·1 answer
  • If a person communicates indirectly and attaches little value to
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!