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
crimeas [40]
3 years ago
14

Write the code for the method getNewBox. The method getNewBox will return a GiftBox that has dimensions that are m times the dim

ensions of its GiftBox parameter, where m is a double parameter of the method.
For example, given the following code segment:
GiftBox gift = new Gift Box (3.0, 4.0, 5.0):
The call
getNewBox , 0, 5).
would return a GiftBox whose dimensions are: length = 1.5, width = 2.0, and height = 2.5 .
Computers and Technology
1 answer:
liraira [26]3 years ago
3 0

Answer:

public class GiftBox{

private int length;

private int width;

private int height;

 

public GiftBox(double length, double width, double height) {

this.length = length;

this.width = width;

this.height = height;

}

 

public static GiftBox getNewBox(GiftBox giftBox, double m) {

return new GiftBox(m * giftBox.length, m * giftBox.width, m * giftBox.height);

}

 

private boolean fitsInside(GiftBox giftBox) {

if(giftBox.length < this.length && giftBox.width <this.width

&& giftBox.height < this.height) {

return true;

}

return false;

}

 

public static void main(String []args){

GiftBox giftBox = new GiftBox(3.0 , 4.0, 5.0);

GiftBox newGiftBox = getNewBox(giftBox, 0.5);

System.out.println("New Box length: " + newGiftBox.length);

System.out.println("New Box width: " + newGiftBox.width);

System.out.println("New Box height: " + newGiftBox.height);

 

GiftBox gift = new GiftBox(3.0 , 4.0, 5.0);

GiftBox other = new GiftBox(2.1 , 3.2, 4.3);

GiftBox yetAnother = new GiftBox(2.0 , 5.0, 4.0);

 

System.out.println(gift.fitsInside(other));

System.out.println(gift.fitsInside(yetAnother));

}

}

Explanation:

The getNewBox is a public method in the GiftBox class in the Java source code above. It returns the GiftBox object instance increasing or multiplying the dimensions by the value of m of type double.

You might be interested in
The set of specific, sequential steps that describe exactly what a computer program must do to complete the work is called a(n)
nataly862011 [7]

Answer:

D). Algorithm

Explanation:

The set of specific, sequential steps that describe exactly what a computer program must do to complete the work is called an algorithm.

From the question, it is clear the correct option is algorithm.

In simple terms, to solve a problem the set of rules to follow is called algorithm. Algorithm in computer programming describes the steps that explains not only the task that needs to be performed, but also how to do it.

In algorithm, the steps are needed to be in the right sequence.

6 0
3 years ago
Read 2 more answers
2
Elza [17]

A is the correct answer.

Hope this helps you!

3 0
4 years ago
Read 2 more answers
A database design where certain data entities are combined, summary totals are carried in the data records rather than calculate
uranmaximum [27]

Answer: Planned data redundancy

Explanation: Planned data redundancy is the problem that occurs in the single database where the same data unit gets stored in two different places. Data redundancy can acquire unnecessary space of the database.

Planned data redundancy can effect the processing and make modification of the data difficult. It can also create the corruption in the database .Thus , the definition mentioned in the question of data redundancy.

5 0
3 years ago
Why can’t web apps send notifications to a device’s taskbar when the app is closed?
tangare [24]
Web apps can't send notifications when it's closed because it is not installed into the device as a software program, meaning it doesn't have enough access to do so. Plus you are closing it down so how is something that you close down supposed to work?
8 0
4 years ago
Write an algorithm to multiply two numbers​
Ilya [14]

Answer:

a+b=c

Explanation:

6 0
3 years ago
Read 2 more answers
Other questions:
  • In Linux, when logged in as a normal user with root privileges, which command must precede the apt-get command in the command li
    13·1 answer
  • What's the first step in being a wise consumer of media?
    10·2 answers
  • Explain why the 7 bit standard ASCII code needs to have the highest bit set to a zero
    11·1 answer
  • What is the maximum transmission speed for bluetooth v3 and v4 devices?
    12·1 answer
  • What material replaced stone as the primary materials used to make tools and machines by humans
    5·1 answer
  • A bug collector collects bugs every day for seven days. Write a program in Python that finds the highest number of bugs collecte
    11·1 answer
  • All of the following are benefits of automation except
    5·1 answer
  • At Chicago Cubs games, residents across the street from Wrigley Field can watch the game from their apartment windows. Many of t
    14·1 answer
  • Match the elements used in web searches to their functions.
    12·1 answer
  • What is a fundamental difference between the SAP platform and the AirBnB platform?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!