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
How to delete audio from powerpoint​
Marta_Voda [28]

Answer:

To delete an audio clip, select the audio icon on the slide and press Delete.

Hope it helps!!!!

4 0
3 years ago
What describes Accenture's approach to automation?
kogti [31]

human center because we describe stuff by what we see and obserevs

4 0
3 years ago
Read 2 more answers
Can you list the answers in order
viva [34]

whats the question?????????????????????

5 0
3 years ago
John is an entrepreneur who plans to enter a franchise contract with a hotel business. Which of these is an advantage that John
ladessa [460]

The answer is C:

In most Franchise businesses, the franchisor provides ongoing guidance and support, and a developed way of doing business. In addition, they offer a higher rate of success as compared to start-up businesses and you may find it easier to secure finances for a franchise. You will get all the benefits that are attached with big businesses for a small business ownership.

3 0
3 years ago
Read 2 more answers
To determine the type of power in use and to determine battery state or charge on a laptop, you ________.: course hero
Kryger [21]
<span> Hover the mouse over the power icon in the notifcation area</span>
3 0
3 years ago
Other questions:
  • The code selection above is taken from the Color Sleuth activity you just completed. This selection would count as an abstractio
    12·1 answer
  • What folder holds 32-bit programs installed in a 64-bit installation of windows?
    12·1 answer
  • A result of the Gibbons v. Ogden (1824) decision was that states​
    11·1 answer
  • A(n) ____ is a user interface that allows users to interact with graphical objects and pointing devices.
    13·1 answer
  • Select the correct answer. Larry finds it easy to run legacy programs and applications in a virtualized environment. How does th
    5·1 answer
  • The ____ preceding a formula alerts excel that you are entering a formula or function and not text
    14·1 answer
  • Is a router on the local network that is used to deliver packets to a remote network?
    15·1 answer
  • Return a version of the given string, where for every star (*) in the string the star and the chars immediately to its left and
    5·1 answer
  • Which of the following is a hand-drawn animation that takes a large amount of time to complete?
    5·1 answer
  • Use your editor to open the cc_data.js file and study the data stored in the staff object to become familiar with its contents a
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!