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
Arturiano [62]
3 years ago
11

For this question you must write a java class called Rectangle and a client class called RectangleClient. The partial Rectangle

class is given below. (For this assignment, you will have to submit 2 .java files: one for Rectangle class and the other one for RectangleClient class.) // A Rectangle stores an (x, y) coordinate of its top/left corner, its width and height. public class Rectangle { private int x; private int y; private int width; private int height; // constructs a new Rectangle with the given inX, inY and inSideLength public Rectangle(int inX, int inY, int inWidth, int inHeight) // returns the fields' values public int
Engineering
1 answer:
Alex Ar [27]3 years ago
6 0

Answer:

Java program is given below. You can get .class after you execute java programs, You can attach those files along with .java classes given , Those .class files are generated ones.

Explanation:

//Rectangle.java class

public class Rectangle {

private int x;

private int y;

private int width;

private int height;

// constructs a new Rectangle with the given x,y, width, and height

public Rectangle(int x, int y, int w, int h)

{

this.x=x;

this.y=y;

this.width=w;

this.height=h;

}

// returns the fields' values

public int getX()

{

return x;

}

public int getY()

{

return y;

}

public int getWidth()

{

return width;

}

public int getHeight()

{

return height;

}

// returns a string such as “Coordinate is (5,12) and dimension is 4x8” where 4 is width and 8 is height. public String toString()

public String toString()

{

String str="";

//add x coordidate , y-coordinate , width, height and area to str and return

str+="Coordinate is ("+x+","+y+")";

str+=" and dimension is : "+width+"x"+height;

str+=" Area is "+(width*height);

return str;

}

public void changeSize(int w,int h)

{

width=w;

height=h;

}

}

======================

//main.java

class Main {

public static void main(String[] args) {

//System.out.println("Hello world!");

//create an object of class Rectangle

Rectangle rect=new Rectangle(5,12,4,8);

//print info of rect using toString method

System.out.println(rect.toString());

//chamge width and height

rect.changeSize(3,10);

//print info of rect using toString method

System.out.println(rect.toString());

}

}

==========================================================================================

//Output

Coordinate is (5,12) and dimension is : 4x8 Area is 32

Coordinate is (5,12) and dimension is : 3x10 Area is 30

========================================================================================

You might be interested in
The electricity generated by wind turbines annually in kilowatt-hours per year is given in a file. The amount of electricity is
Anika [276]

Answer:

Steps:

1. Create a text file that contains blade diameter (in feet), wind velocity (in mph) and the approximate electricity generated for the year

2.  load the data file for example, in matlab, use ('fileame.txt') to load the file

3. create variables from each column of your data

  for example, in matlab,  

     x=t{1}

     y=t{2}

4. plot the wind velocity and electricity generated.

   plot(x, y)

5. Label the individual axis and name the graph title.

    title('Graph of wind velocity vs approximate electricity generated for the year')

     xlabel('wind velocity')

     ylabel('approximate electricity generated for the year')

5 0
3 years ago
Read 2 more answers
In details and step-by-step, show how you apply the Bubble Sort algorithm on the following list of values. Your answer should sh
astraxan [27]

( 12 17 18 19 25 )

<u>Explanation:</u>

<u>First Pass:</u>

( 19 18 25 17 12 ) –> ( 18 19 25 17 12 ), Here, algorithm compares the first two elements, and swaps since 19 > 18.

( 18 19 25 17 12 ) –> ( 18 19 25 17 12 ), Now, since these elements are already in order (25 > 19), algorithm does not swap them.

( 18 19 25 17 12 ) –> ( 18 19 17 25 12 ), Swap since 25 > 17

( 18 19 17 25 12 ) –> ( 18 19 17 12 25 ), Swap since 25 > 12

<u>Second Pass:</u>

( 18 19 17 12 25 ) –> ( 18 19 17 12 25 )

( 18 19 17 12 25 ) –> ( 18 17 19 12 25 ), Swap since 19 > 17

( 18 17 19 12 25 ) –> ( 18 17 12 19 25 ), Swap since 19 > 12

( 18 17 12 19 25 ) –> ( 18 17 12 19 25 )

<u>Third Pass:</u>

( 18 17 12 19 25 ) –> ( 17 18 12 19 25 ), Swap since 18 > 17

( 17 18 12 19 25 ) –> ( 17 12 18 19 25 ), Swap since 18 > 12

( 17 12 18 19 25 ) –> ( 17 12 18 19 25 )

( 17 12 18 19 25 ) –> ( 17 12 18 19 25 )

<u>Fourth Pass:</u>

( 17 12 18 19 25 ) –> ( 12 17 18 19 25 ), Swap since 17 > 12

( 12 17 18 19 25 ) –> ( 12 17 18 19 25 ), Swap since 18 > 12

( 12 17 18 19 25 ) –> ( 12 17 18 19 25 )

( 12 17 18 19 25 ) –> ( 12 17 18 19 25 )

Now, the array is already sorted, but our algorithm does not know if it is completed. The algorithm needs one whole pass without any swap to know it is sorted.

<u>Fifth Pass:</u>

( 12 17 18 19 25 ) –> ( 12 17 18 19 25 )

( 12 17 18 19 25 ) –> ( 12 17 18 19 25 )

( 12 17 18 19 25 ) –> ( 12 17 18 19 25 )

( 12 17 18 19 25 ) –> ( 12 17 18 19 25 )

6 0
3 years ago
The tropics receive more heat from the sun than is radiated away from the tropics, and polar regions radiate more than they rece
IRINA_888 [86]

Answer:

It is a well known fact that the earth rotates around the sun in an inclined axis which is approximately 23 degree. The inclined nature of earth axis causes variation in the solar heat received at any place on the earth surface. The hemisphere facing the sun due to this axial tilt, gets higher sun energy as compared to the opposite side. The hemisphere which faces the sun will experience summer whereas the hemisphere away from sun will experience winter.

In each of the hemisphere the polar areas will receive higher radiation and longer daytime during the summer season. However it has been observed that there is difference in radiation received at different areas of earth surface and radiated. The tropical areas have lower reflectance and thus a large part of incoming solar radiation have been absorbed along the tropics. The poles though have longer daytime during summer and hence greater solar radiation but due to high reflectance radiate more energy. Thus the tropical areas have surplus energy as compared to deficit energy areas of poles. This difference in energy creates a heat imbalance.

This net heat difference between poles and equator gives rise to a global circulation system leading to flow of heat from the net energy excess areas to deficit areas. This circulation takes place through atmosphere as well as oceans and different process of climate viz. evaporation, transpiration, rainfall, wind, convection, oceanic circulations etc work as tools of this system

4 0
3 years ago
A heat recovery system​ (HRS) is used to conserve heat from the surroundings and supply it to the Mars Rover. The HRS fluid loop
blagie [28]

Answer:

0.304 L of Freon is needed

Explanation:

Q = mCT

Q is quantity of energy that must be removed = 47 BTU = 47×1055.06 = 49587.82 J

C is specific heat of Freon = 74 J/mol.K = 74 J/mol.K × 1 mol/120 g = 0.617 J/g.K

T is temperature in the area of Mars = 189 K

m = Q/CT = 49587.82/(0.617×189) = 452.23 g = 452.24/1000 = 0.45223 kg

Density of Freon = specific gravity of Freon × density of water = 1.49 × 1000 kg/m^3 = 1490 kg/m^3

Volume of Freon = mass/density = 0.45223/1490 = 0.000304 m^3 = 0.000304×1000 = 0.304 L

7 0
3 years ago
14. A large car fire presents the possibility of
dexar [7]

Answer:

Both of the above

Explanation:

5 0
3 years ago
Read 2 more answers
Other questions:
  • Compute the fundamental natural frequency of the transverse vibration of a uniform beam of rectanqular cross section, with one e
    11·2 answers
  • Some chemical reaction is being run inside a sealed gas cylinder. During the reaction, a gaseous product is formed. The pressure
    14·1 answer
  • A common chef's knife is single-beveled.<br> TRUE<br> FALSE
    10·1 answer
  • 1 kg of oxygen is heated from 20 to 120°C. Determine the amount of heat transfer required when this is done during a (a) constan
    7·1 answer
  • The coefficient of performance of a reversible refrigeration cycle is always (a) greater than, (b) less than, (c) equal to the c
    12·1 answer
  • How much memory can a 32 -bit processor support ?
    13·1 answer
  • What parts do all circuits have in common?
    9·2 answers
  • Help please!!!!!
    12·1 answer
  • que sabemos de la revolución industrial y como ese proceso impulso el uso de los controles eléctricos en las industrias
    6·1 answer
  • There are signs of oil spray on the compressor clutch hub and nearby underhood areas. Technician A says that a faulty compressor
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!