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
nasty-shy [4]
3 years ago
14

In this lab, you will create a programmer-defined class and then use it in a Java program. The program should create two Rectang

le objects and find their area and perimeter.InstructionsMake sure the class file named Rectangle.java is open.In the Rectangle class, create two private attributes named length and width. Both length and width should be data type double.Write public set methods to set the values for length and width.Write public get methods to retrieve the values for length and width.Write a public calculateArea() method and a public calculatePerimeter() method to calculate and return the area of the rectangle and the perimeter of the rectangle.Open the file named MyRectangleClassProgram.java.In the MyRectangleClassProgram class, create two Rectangle objects named rectangle1 and rectangle2.Set the length of rectangle1 to 10.0 and the width to 5.0. Set the length of ectangle2 to 7.0 and the width to 3.0.
Computers and Technology
1 answer:
prohojiy [21]3 years ago
7 0

Answer:

class Rectangle{

//private attributes of length and width

private double givenLength;

private double givenWidth;

// constructor to initialize the length and width

public Rectangle(double length, double width){

 givenLength = length;

 givenWidth = width;

}

// setter method to set the givenlength

public void setGivenLength(double length){

 givenLength = length;

}

// setter method to set the givenWidth

public void setGivenWidth(double width){

 givenWidth = width;

}

// getter method to return the givenLength

public double getGivenLength(){

 return givenLength;

}

// getter method to return the givenWidth

public double getGivenWidth(){

 return givenWidth;

}

// method to calculate area of rectangle using A = L * B

public void calculateArea(){

 System.out.println("The area of the rectangle is: " + getGivenLength() * getGivenWidth());

}

// method to calculate perimeter of rectangle using P = 2 * (L + B)

public void calculatePerimeter(){

 System.out.println("The perimeter of the rectangle is: " + 2 * (getGivenLength() + getGivenWidth()));

}

}

public class MyRectangleClassProgram{

public static void main(String args[]){

//rectangle1 object is created

Rectangle rectangle1 = new Rectangle(10.0, 5.0);

//rectangle2 object is created

Rectangle rectangle2 = new Rectangle(7.0, 3.0);

//area for rectangle1 is calculated

rectangle1.calculateArea();

//perimeter for rectangle1 is calculated

rectangle1.calculatePerimeter();

//area for rectangle2 is calculated

rectangle2.calculateArea();

//perimeter for rectangle2 is calculated

rectangle2.calculatePerimeter();

}

}

Explanation:

Two file is attached: Rectangle.java and MyRectangleClassProgram.java

Download java
<span class="sg-text sg-text--link sg-text--bold sg-text--link-disabled sg-text--blue-dark"> java </span>
<span class="sg-text sg-text--link sg-text--bold sg-text--link-disabled sg-text--blue-dark"> java </span>
You might be interested in
Select the correct answer from each drop-down menu. Select the correct type of address reference.
Reika [66]

<u><em>[ Absolute ]</em></u><em> Addresses do not change if you copy them to a different cell.</em>

<u><em>[ Relative ]</em></u><em> </em><em>Addresses change depending on the cells you copy them to.</em>

8 0
2 years ago
Read 2 more answers
What are the different types of topology?​ in details
wlad13 [49]

Answer:

<h2> <u>NETWORK</u> <u>TOPOLOGY</u> .</h2>

This tefers to how nodes are connected to the network.

Types of topology.

  • Physical topology.
  • Logical topology.

In physical topology,nodes are connected physically using wires(cables).

Types of physical topology include:

  • Bus topology
  • Tree topology
  • Hybrid topology
  • Star topology
  • Ring topology.

Hope it helps you,any question so far...comment !!!

3 0
1 year ago
Read 2 more answers
10. Two technicians are discussing recycling specifications for refrigerant. Technician A says that refrigerant oil with 5,000 p
NARA [144]

Answer:

a

Explanation:

8 0
2 years ago
Which term best describes a popular marketing strategy that centers
IceJOKER [234]

Answer:

Customer Relationship Management (CRM).

Explanation:

CRM is an acronym for customer relationship management and it typically involves the process of combining strategies, techniques, practices and technology so as to effectively and efficiently manage their customer data in order to improve and enhance customer satisfaction.

This ultimately implies that, these employees are saddled with the responsibility of ensuring the customer are satisfied and happy with their service at all times.

Marketing can be defined as the process of developing promotional techniques and sales strategies by a firm, so as to enhance the availability of goods and services to meet the needs of the end users or consumers through advertising and market research. It comprises of all the activities such as, identifying, anticipating set of medium and processes for creating, promoting, delivering, and exchanging goods and services that has value for customers.

Basically, CRM involves understanding customer needs, building and maintaining healthy long-term relationships with them, in order to add value or scale up your business.

Hence, customer relationship management (CRM) is one of the popular marketing strategy that is mainly based on the acquisition, enhancement, and retention of long-term relationships that add value for the organization and the customer.

8 0
2 years ago
¿como la imagen organiza la realidad?
Troyanec [42]

Answer:

Las imágenes son las percepciones visuales que las personas tienen respecto de la realidad que los rodea. Así, a través de la visión, las personas pueden interpretar el contexto en el cual se encuentran inmersos, organizando los distintos componentes de la realidad en la cual desarrollan sus vidas, para poder comprender entonces de qué modo proceder ante las diferentes eventualidades de la vida.

Es decir que, a través de las imágenes, y en conjunto con las demás percepciones sensoriales, los seres humanos pueden contextualizarse en un entorno en el cual se desenvuelven, organizando su vida y su realidad a futuro.

7 0
2 years ago
Other questions:
  • Most licensing agencies offer an orientation meeting for applicants who want to obtain licensing for a child care facility or a
    12·2 answers
  • Indicate the proper order (1-4) of the following PR strategic planning 4-step process. 1 Defining the problem 2 Evaluating the p
    10·1 answer
  • Sonic the Hedgehog (1991)
    14·1 answer
  • PLZ help
    5·1 answer
  • 2:3:5<br>_ _ _<br>3 2 8<br><br><br><br>find ratio​
    5·1 answer
  • Four actions that can be implemented on a database to autocorrect violations of referential integrity, and the outcomes of the a
    15·1 answer
  • Specific keys that each finger is responsible for typing is called A. ergonomics B. Touch typing C. Key reaches D. Posture
    8·1 answer
  • Write a program that reads a list of integers, and outputs the two smallest integers in the list, in ascending order. The input
    5·1 answer
  • What are the common camera hazards? When might you encounter these hazards in your life, and what do you plan to
    14·1 answer
  • The Internet is a worldwide communications network. Which device connects computer networks and computer facilities?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!