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
What is the difference between (IF instructions &amp; WHILE instructions )<br> 0<br> 를 들<br> T<br> !
lara31 [8.8K]

Answer:

While statements determine whether a statement is true or false. If what’s stated is true, then the program runs the statement and returns to the first step. If what’s stated is false, the program exits the while and goes to the next statement. An added step to while statements is turning them into continuous loops. If you don’t change the value so that the condition is never false, the while statement becomes an infinite loop.

If statements are the simplest form of conditional statements, statements that allow us to check conditions and change behavior/output accordingly. The part of the statement following the if is called the condition. If the condition is true, the instruction in the statement runs. If the condition is not true, it does not. The if statements are also compound statements. They have a header (if x) followed by an indented statement (an instruction to be followed is x is true). There is no limit to the number of these indented statements, but there must be at least one.

7 0
3 years ago
what should the timing of transition slides be per minute? maintain the flow of the presentation to ______ slides per minute.
murzikaleks [220]

Answer:

1-2

Explanation:

It depends on the amount of information that you have on each slide. You want to make sure you're not going too fast but also make sure you arent taking up to much time. Be sure to speak clearly it will make the presentation better by looking clean and time organized. hope this helps :)

8 0
3 years ago
You have just installed the microsoft windows 7 operating system on your pc. which web browser is bundled with windows 7 and is
kirill [66]
The web browser that is automatically installed with windows 7 is Internet Explorer.

Hope this helps.
6 0
4 years ago
1.- Make a program that loops and perform powers of 5 on each loop.
Olin [163]

A program that loops and performs powers of 5 on each loop.In each lap the operator is asked IN CODE C++ the C++ Program for the given hassle announcement is as follows:#include the use of namespace std.

<h3>What is the energy of a variety of?</h3>

The energy of a variety of says how usually to apply the range in a multiplication. Powers also are known as Exponents or Indices. For example, eight^2 might be known as “eight to the energy 2” or “eight to the second one energy”, or simply “eight square.

  1. C++ Program for the given hassle announcement is as follows:
  2. #include
  3. the use of namespace std;
  4. int main() > base;
  5. cout << "nEnter the exponent: ";     //asks the user for keyboard input for exponent
  6. cin>>exponent;
  7.  for (int i = 1; i <=exponent; i++)    //iterate {through|thru|via">via 1 until exponent
  8. {
  9.       num=num*base;
  10. //base is multiplied (e.g. 2*2*2.....n) until n, wherein n is exponent
  11.    }
  12. cout <<"n"<strength of "<go back 0;
  13. }
  14. Sample Output:
  15. Stdin Inputs

Read more about the loops :

brainly.com/question/26497128

#SPJ1

6 0
2 years ago
if i were to buy one of these and plug it into a ps4 usb slot would i be able to see it on a tv? cause my hdmi slot on the ps4 i
alisha [4.7K]
It should work unless you did or bought the wrong thing
7 0
3 years ago
Read 2 more answers
Other questions:
  • An example of hardware is a _____. database spreadsheet monitor program used to enhance photos
    13·2 answers
  • Which is a function of network media?
    14·2 answers
  • why do networking components need more examination from an information security perspective than from a systems development pers
    5·1 answer
  • One of the ways to create a horizontal navigation menu from an unordered list is to a. set the display property of the element w
    6·1 answer
  • blank protects equipment from too much current by tripping a switch that breaks the circuit, stopping the flow of electricity
    7·1 answer
  • A media strategy that involves high ________ most likely involve creating broad exposure using many media vehicles, while a stra
    15·1 answer
  • This is Very very Important to me[BRAINLIEST)✅​
    5·1 answer
  • Software that allows users to use and adapt it for any purpose, often allowing the public to participate in further development
    7·2 answers
  • Place the steps for attaching a file to a message in order from top to bottom.
    12·1 answer
  • You can use these finger motions to perform specific functions on a Mac OS system:
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!