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
that average july high temperature is 85 degrees fahrenheit in new york, 88 degrees fahrenheit in denver, and 106 degrees fahren
goblinko [34]

Answer:

public class num8 {

   public static void main(String[] args) {

       System.out.println("Average Temperature in New York is 85 degrees fahrenheit");

       System.out.println("Average Temperature in Denver is 88 degrees fahrenheit");

       System.out.println("Average Temperature in Phoenix is 106 degrees fahrenheit");

   // Calculating the new average Temperatures

       System.out.println("The New Average Temperature in New York " +

               "is "+ ((0.02*85)+85 )+ " degrees fahrenheit");

       System.out.println("The New Average Temperature in Denver " +

               "is " +((0.02*88)+88 )+ " degrees fahrenheit");

       System.out.println("The New  Average Temperature in Phoenix " +

               "is "+((0.02*106)+106 )+ " degrees fahrenheit");

   }

}

Explanation:

  1. Using Java first display the previous average temperatures for the three cities as given in the question
  2. Then calculates the new average temperature by multiplying by 0.02, because of a 2 percent increase in the average temperature
  3. Display the new temperature using the System.out,println

8 0
3 years ago
What would be the most professional choice of words for your response:
Naddika [18.5K]

The professional choice of words for response is I wanted to help you protect my coworker’s privacy by letting you know I received this message intended for her.

Check more about writing below.

<h3>What is “Word Choice” in Writing? </h3>

'Word Choice” in writing is known to be a term that connote the ways or the usage of words that is said to be effective and precise use of language.

This is one that often conveys information and it also tends to enlighten the reader.

Note that option C is correct because it is best and most professional way to respond to a statement.

Hence, The professional choice of words for response is I wanted to help you protect my coworker’s privacy by letting you know I received this message intended for her.

Learn more about word choices from

brainly.com/question/1619714

#SPJ1

3 0
2 years ago
What is the difference between software and operating system software?
Basile [38]

Answer:

System software is the software that manages the resources and allows a user to interact with the system. On the other hand, an operating system collects programs that coordinate all activities among computer hardware devices.

4 0
3 years ago
What is the term for a problem in your code
Anna71 [15]

Answer:

bug

Explanation:

Bug

a problem in your code

7 0
3 years ago
Read 2 more answers
Select all that apply.
Ierofanga [76]
Insert option the last one
3 0
3 years ago
Read 2 more answers
Other questions:
  • A ____ database supports data distributed across several different sites.
    7·1 answer
  • How would Microsoft Word inform you of the error in the sentence below? (Tip: The error is in bold.)
    7·1 answer
  • You would like the user of a program to enter a customer’s last name. Write a statement thaUse the variables k, d, and s so that
    5·1 answer
  • As the project manager for a software development project, you are helping to develop the project schedule. You decide that writ
    13·1 answer
  • True false) keybord has two shift keys.​
    15·1 answer
  • ABC Resort and Hotel has approached you to write a program to keep track of the number of rooms needed for an event. Customers c
    14·1 answer
  • Hey! Would you please help me do this program?
    14·1 answer
  • How can you use Word in order to edit and print documents ?
    14·1 answer
  • Jayden wants to take a current theme but just change a little bit of it. Complete the steps to help Jayden.
    12·1 answer
  • what is the arrangement of various flash elements, such as the tools panel, control panel, property inspector and stage
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!