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

Use the script below as a starting point to create a Rectangle class. Your rectangle class must have the following methods;A con

structor that takes a length and width as parametersgetArea - returns the area of the rectangleisSquare - returns True if length and width are equivalentoverloaded equivalence - compares the length and width of two rectangles and returns true if they are equivalent
Computers and Technology
1 answer:
Greeley [361]3 years ago
4 0

Answer:

The solution code is written in Java.

  1. public class Rectangle {
  2.    private double length;
  3.    private double width;
  4.    public Rectangle(double length, double width){
  5.        this.length = length;
  6.        this.width = width;
  7.    }
  8.    public double getArea(){
  9.        return this.length * this.width;
  10.    }
  11.    public boolean rectangleSquare(){
  12.        if(this.length == this.width){
  13.            return true;
  14.        }else{
  15.            return false;
  16.        }
  17.    }
  18.    public boolean equivalence(Rectangle rect){
  19.        if(this.width == rect.width && this.length == rect.length){
  20.            return true;
  21.        }else{
  22.            return false;
  23.        }
  24.    }
  25. }

Explanation:

Create a class, <em>Rectangle</em> (Line 1) and define two private attributes,<em> width </em>and <em>length</em> (Line 3 - 4). The reason to define the attributes as <em>double</em> type is because the width and length are presumed to be either an integer or a decimal value.

Create constructor which takes <em>width</em> and<em> length </em>as parameters (Line 6).

Next, the require methods, getArea(), isSquare() and overloaded equivalence() along with their expected parameters and return output, are created accordingly in Line 11 -28.

You might be interested in
Which of the following best explains how the Internet is a fault-tolerant system?
IrinaK [193]

Answer:

A

Explanation:

The Internet is fault-tolerant because cybercriminals can conceal their actions, allowing them the ability to carry out faulty actions without leaving a trace.

This statement is actually the same question I had to answer when in my 2nd year 1st semester in itt.
<3 enjoy

8 0
2 years ago
Read 2 more answers
The primary key is a field that uniquely and completely identifies a record.
Leokris [45]
True

----------------------------------
6 0
3 years ago
Read 2 more answers
5. Write a program to remove any duplicate letters from a word and display the new word maintaining the original order. For exam
dexar [7]

Answer:

word = input('Enter a single word: ', 's');

n = length(word);

nodupWord = [];

for i = 1:n

  dup = false;

  c = word(i);

  for j = 1:i-1

      if word(j) == c

          dup = true;

          break;

      end

  end

  if ~dup

      nodupWord = [nodupWord, c]; %add the non-duplicate char to end

  end

end

disp(['Adjusted word: ', nodupWord])

Explanation:

The code is in Python.

3 0
3 years ago
Which of the following applications can be used as a data source for a Microsoft® Word® mail merge? A.Outlook Contacts B.Microso
Xelga [282]
<span>Word can pull data from a variety of data sources to perform a mail merge. As part of the Microsoft Office suite, Word easily accepts data from Outlook, Excel, and Access, and other data sources such as web pages, OpenDocument text files, and delimited data files stored as plain text. And if you don't have an existing data source, you can create a new one in Word.
ALL OF THE ABOVE

</span>
8 0
3 years ago
Read 2 more answers
The steps for creating a newsletter are to ____.
leonid [27]

Answer:

C) Plan, write, format, and proofread

Explanation:

You need a plan for any professional newspaper. Proofreading is also a vital step in the process. You can only format what you've already written, so it has to be C.

4 0
2 years ago
Other questions:
  • What are three new things in Microsoft Word 2016?
    5·1 answer
  • This type of connection uses radio waves to connect devices on a network.
    15·2 answers
  • At the frequency of 2.4 GHz what is the free-space path loss in dB.
    9·1 answer
  • Diane is receiving a lot of unwanted e-mail. What steps can she take to reduce the amount of e-mail she receives?
    12·1 answer
  • in java how do i Write a program that reads a set of integers, and then prints the sum of the even and odd integers.
    6·1 answer
  • How do i delete an account for brainly how do i delete everything
    7·2 answers
  • What type of error results from an error in the formatting of the program code?
    13·1 answer
  • How are online sources used? Check all that apply.
    8·2 answers
  • PLS I NEED HELP Question 6<br> 1 pts<br> What is NOT a built-in function in python?
    5·1 answer
  • define a computer, state its 3 main activities with examples of the functions of each of those activities​
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!