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
Harrizon [31]
3 years ago
10

Write a program named RectangleArea to calculate the area of a rectangle with a length of 15.8 and a width of 7.9. The program s

hould have two classes, one is the RectangleArea holding the Main(), and the other one is Rectangle. The Rectangle class has three members: a property of length, a property of width, and a method with a name of CalArea() to calculate the area. You can invoke the auto-provided constructor or write a self-defined constructor to initialize the rectangle. Calculate and display the area of the rectangle by first initialize an object named myRectangle and then calculate its area using the CalArea() method.
Computers and Technology
1 answer:
stiv31 [10]3 years ago
4 0

Answer:

public class RectangleArea {

   public static void main(String[] args) {

       Rectangle myRectangle = new Rectangle(15.8, 7.9);

       double calArea = myRectangle.calcArea(15.8, 7.9);

       System.out.println("The area is "+ calArea);

   }

}

class Rectangle{

   private double length;

   private double width;

   //Defined Constructor

   public Rectangle(double length, double width) {

       this.length = length;

       this.width = width;

   }

   public double calcArea(double len, double wi){

       return len* wi;

   }

}

Explanation:

  • This is solved with Java programming language
  • Start by creating both classes RectangleArea and and Rectangle
  • SInce both classes are in the same file, only one can be public
  • Class Rectangle contains the three members are decribed by the question
  • private double length, private double width and the method calcArea(). It also has a sefl-declared constructor.
  • In the class RectangleArea, an object of Rectangle is created and initialized.
  • The method calcArea is called using the created object and the value is printed.
You might be interested in
Plsss help me<br><br>1)give 2 examples of systems that you use or see in your day-to-day life​
Gnoma [55]

Answer:

The modern world has numerous kinds of systems that influence daily life. Some examples include transport systems; solar systems; telephone systems; the Dewey Decimal System; weapons systems; ecological systems; space systems; etc.

5 0
3 years ago
What is the Multiple Items tool?
Dmitry_Shevchenko [17]

Explanation:

when a form is created in Microsoft Access using the form tool it displays a single record at a time.To display multiple records and the form should be more customizable then in this case we use Multiple Items tool.

Creating a form using Multiple Items Tool:-

In navigation pane click query or table which contains the data that we want to see on the form.

On create tab,in the group Forms,click more Forms,then click Multiple Items.

6 0
3 years ago
Which of the following is not included in the manufacturing industry cluster?
max2010maxim [7]
Printing is not included in the manufacturing industry cluster
6 0
3 years ago
Read 2 more answers
Elliott is trying to normalize a database that he has designed. Which is not one of the elements of 1NF or 2NF?
Kruka [31]
D. each table must depend on the entire foreing key
4 0
1 year ago
List three different computer languages, and describe how each one is used in software development
Bumek [7]
JavaScript- Used in designing websites

Python- Used in developing desktop and web applications

C++ Used in Video games, operating systems such as Windows 10, and device drivers.
6 0
3 years ago
Other questions:
  • Write a program that uses a 2-D array to store the highest and lowest temperatures for each month of the year. The program shoul
    14·1 answer
  • When viewing data entered into a spreadsheet, the columns identify _____.?
    5·1 answer
  • The calls radioed to patrol officers, or assignments given to police patrol units by 911 dispatchers, reveal the types of proble
    9·1 answer
  • A thin red border indicates the active cell. (True or False)
    12·1 answer
  • How is kerning used in Word?
    7·2 answers
  • On the server side, the database environment must be properly configured to respond to clients' requests in the fastest way poss
    12·1 answer
  • You recently started working part-time in a retail store, and are learning about the reading devices your store uses. Your store
    6·1 answer
  • What is wrong with the following C++ code? How would you fix it? int sum; for (int i=0; i&lt;1000; ++i) sum += i; { printf("Sum
    5·1 answer
  • Please tell fast plzzzzzzzz​
    11·2 answers
  • Translate the following pseudocode for randomly permuting the characters in a string into a C++ program.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!