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
What method does a GSM network use to separate data on a channel?
Sergeu [11.5K]

Answer: TDMA(Time division multiple access)

Explanation: Time-division multiple access is the method that is used by GSM(Global system for mobile communication) usually for the separation process of the data.It is a way in which a same frequency is shared by different time slots of signal.It has high flexibility and so thus is helpful for the GSM network and provides easy services of division.It divides the data according to the time period slots in a GSM network.

4 0
3 years ago
The ____________ is an interest inventory that classifies people according to six different types: Realistic, Investigative, Art
Kamila [148]
1) C) Campbell Interest Inventory.

Also known as the Strong Interest Inventory, this was developed based on the Holland Codes (6 traits listed in the question), it was developed by psychiatrist Edward Strong and later revised by David Campbell. 

2) C) FOCUS2

The FOCUS2 test is a test that matches students with study programs based on their assessed aptitudes and interests. <span />
7 0
3 years ago
Read 2 more answers
What’s my password for this app
FrozenT [24]

Answer:

I guess there isnt any password!

Explanation:

7 0
3 years ago
Read 2 more answers
Cuales son los multiplos de un byte
GalinKa [24]

Answer:

I hope this works for u

Explanation:

1 GIGABYTE = 1Gb = 1024 Mb = 1.000.000.000 bytes. 1 TERABYTE = 1Tb = 1024 Gb = 1 billon de bytes. 1 PETABYTE = 1Pb = 1024 Tb = Mill billones de bytes. 1 EXABYTE = 1 Eb = 1024 Pb = 1 trillon de bytes.

Can I have a brainliest..

Puedo tener un brainliest

Plz :3

8 0
3 years ago
Creating an application for an ice cream shop. Create an interface named Flavor. Create three subclasses Lemon, Mint, and Chocol
Tpy6a [65]

Answer:

I don't know for sure what the answer is but I hope you can find someone that can give you the answer sorry!

Explanation:

6 0
2 years ago
Other questions:
  • After doing the route tracing to a particular IP addresses, paste the path of IP addresses that were taken from your IP address
    13·1 answer
  • _________ involves encouraging employees to engage in behaviors directly related to goal accomplishment.
    6·1 answer
  • What are two examples of ways an electronic record may be distributed to others?
    15·1 answer
  • 1. If this traffic signal is turned on after the red light, it means you may cross the intersection, but you _______ wait until
    12·2 answers
  • Cell references in a formula are called _____.<br> a. assumptionsc. numbersb. valuesd. content
    11·1 answer
  • The ________ option contains the formatting and placeholders for all of the items that appear on a side.
    11·1 answer
  • Describe how communication strengthens relationship at work and, as a result, increases your productivity
    9·1 answer
  • Why is it easier to spot a syntax error than a logical error?​
    10·2 answers
  • You develop an app, and you don't want anyone to resell it or modify it. This is an example of: A an operating system. B open so
    11·2 answers
  • Which sentence uses parallel structure correctly?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!