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
How is kerning used in Word?
kirill115 [55]

Answer: To adjust the spacing between characters that make up a word

Explanation: Kerning refers to the way spacing between two specific characters is adjusted. The idea is to give a better looking result by reducing the spacing between characters that fit together nicely (such as "A" and "V") and increasing the spacing between characters that don't. Select the text that you want to change.

4 0
2 years ago
How to improve and create beautiful graphic
kaheart [24]

Answer:

Learn OpenGL and any graphics rendering program.

Explanation:

3 0
3 years ago
Who go to Tennessee Connection Academy And If yall Do plz comment down below.
zalisa [80]

Answer:

it a or d

Explanation:

7 0
3 years ago
Contemporary Information Systems are interfacing with customers andsuppliers using:A. Electronic commerceB. CRMC. SCMD. all of t
ch4aika [34]

Answer:

D. all of the above

Explanation:

Contemporary Information Systems are interfacing with customers andsuppliers using, electronic commerce, CRM, and SCM.

7 0
3 years ago
An organization needs to maintain data files of its employees in the form of tables. They also need to access and update over th
QveST [7]
DBMS (DataBase Management System)
6 0
3 years ago
Read 2 more answers
Other questions:
  • What is the difference between a denial-of-service attack and a distributed denial-of-service attacks? which is potentially more
    10·1 answer
  • What do you like to play
    13·2 answers
  • Which action is LEAST important to maintaining a healthy credit score?
    8·2 answers
  • What do i study to become a network engineer?
    11·1 answer
  • How can i learn about networks
    15·1 answer
  • What is the autocad term for standard section line symbols?
    13·1 answer
  • Often technical personnel who are not familiar with security techniques think that restricting access to ports on a router or fi
    5·1 answer
  • What are the main types of database end users,? Discuss the main activi-ties of each
    10·1 answer
  • Which of the listed tools would a barber likely use in the following scenario?
    15·1 answer
  • If I use the command right(90), which way will Tracy turn?<br> If correct I mark brainlist
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!