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
Helga [31]
3 years ago
11

Within MethodsPractice.java, write a method public static int planParty2(int f, int c, int p) that performs the same calculation

s as the previous problem, but returns the number of p-packs needed. planParty2 does not need to consider the number of extra cans, and it should not print anything. Here are some example arguments for the planParty2 method and their expected return values:

Computers and Technology
1 answer:
Vesna [10]3 years ago
3 0

Answer:

// class definition of MethodPractice

public class MethodPractice {

   // main method that begin program execution

   public static void main(String args[]) {

       // call to the planParty2 method is done using some parameter

       // and the return value is displayed

     System.out.println("The number of p-packs needed is: " + planParty2(9, 14, 6));

     System.out.println("The number of p-packs needed is: " + planParty2(4, 6, 3));

     System.out.println("The number of p-packs needed is: " + planParty2(4, 6, 4));

   }

   

   // planParty2 method with 3 parameters and it return an integer

   // the calculation needed to get the required pack is done here

   public static int planParty2(int f, int c, int p){

       // the party owner is added to list of friend

       // and the value is assigned to totalPeople

       int totalPeople = f + 1;

       // the totalPeople times the can drink

       // is assigned to totalDrinkNeeded

       int totalDrinkNeeded = totalPeople * c;

       // number of packs required is declared

       int numberOfPacks;

       // if the totalDrinkNeeded contains exact multiple of a pack

       // we return the numberOfPack by dividing totalDrinkNeeded with p

       if (totalDrinkNeeded % p == 0){

           return numberOfPacks = totalDrinkNeeded / p;

       }

       // else we compute if the totalDrinkNeeded is not a multiple of a pack

       //  first we get the remainder when the totalDrinkNeeded is divided with p

       // then the needed can is computed by subtracting remainder from p

       // the neededCan is added to totalDrinkNeeded, then divided with p

       // and assigned to numberOfPacks

       // numberOfPacks is returned.

       else {

           int remainder = totalDrinkNeeded % p;

           int neededCan = p - remainder;

           numberOfPacks = (totalDrinkNeeded + neededCan) / p;

           return numberOfPacks;

       }

   }

}

Explanation:

Image showing the detailed question is attached.

The program is written in Java and is well commented. A sample image of program output when it is executed is attached.

You might be interested in
A centralized structure does not provide information from local stores that would be useful in changing its technology quickly.
mylen [45]
<span>The statement that "A centralized structure does not provide information from local stores that would be useful in changing its technology quickly is an example that illustrates the effect of structure on strategy" is true. 
</span><span> Changes in the external environment are the reason why changes in the technology and emergence of dynamic technological advancements should be done.</span>
7 0
3 years ago
Innovation made from establishment of abucas to the present 5th
Minchanka [31]

Answer:

Douglas-fir, spruce, true fir, beech, and maple are toward the top of the list for oxygen release.Douglas-fir, spruce, true ...

4 0
3 years ago
Designers are comparing performance between a multi-core processor equipped with 16 in-order cores and a dual-core superscalar p
Nataly [62]

Explanation:

it will be k because it process faster an it comsume less elecricity

5 0
2 years ago
A __________ note is a private note that you leave for yourself or for other people who might use the presentation file
BaLLatris [955]

Answer:

The answer is that it is a speaker note.

Explanation:

It leaves a note for people that use presentation files. I use it all the time on my google slides.

7 0
2 years ago
HELP PLEASE
atroni [7]

Answer: The role of a public relations manager is to keep the image of a celebrity, politician, ect. good so that they can keep their career going while constantly in the eye of the public. Public figures may find this useful because it can help them keep their record clean and have a personal life while also making it seem like they are perfect people to their audience, which in hand can help with business.

Explanation:

5 0
2 years ago
Other questions:
  • When a relationship is established between two or more arrays by using the same subscript to relate entries between the arrays,
    14·2 answers
  • By generating and delivering timely and relevant information supported by networks, _____ creates new opportunities for conducti
    15·1 answer
  • What is output? <br> Print (12 % 5)<br><br> Answer <br> 0<br> 5<br> 2<br> 1
    12·2 answers
  • Define function print_popcorn_time() with parameter bag_ounces. If bag_ounces is less than 3, print "Too small". If greater than
    5·1 answer
  • Look at the data set below. {9, 12, 12, 15, 18, 20, 25} in this data set, what is the median
    5·2 answers
  • Gabe wants to move text from one document to another document. He should _____.
    9·2 answers
  • Suppose that the instruction format for a modified Little Man Computer requires two consecutive locations for each instruction.
    5·1 answer
  • The Arizona Department of Transportation has offices throughout the state. State documents are stored on a large server in a cen
    5·2 answers
  • Determine what is printed by the following code.
    8·1 answer
  • What is the difference between a computer’s RAM and its hard disk?
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!