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
susan wrote the recursive formula for the sequence represented by the exploit formula An=3+2n. put an C net to any correct state
omeli [17]

The recursive formula of the explicit formula A_n = 3 + 2n is A_n = A_{n-1} + 2

The explicit formula is given as:

A_n = 3 + 2n

When n = 1, we have:

A_1 = 3 + 2(1)

A_1 = 5

When n = 2, we have:

A_2 = 3 + 2(2)

A_2 = 7

When n = 3, we have:

A_3 = 3 + 2(3)

A_3 = 9

So, we have:

A_1 = 5

A_2 = 7

A_3 = 9

Rewrite the functions as follows:

A_1 = 5

A_2 = 5 + 2

A_3 = 7 + 2

So, we have:

A_1 = 5

A_2 = A_1 + 2

A_3 = A_2 + 2

Express 2 as 3 - 1

A_3 = A_{3-1} + 2\\

Substitute n for 3

A_n = A_{n-1} + 2

Hence, the recursive formula is A_n = A_{n-1} + 2

Read more about recursive and explicit formulas at:

brainly.com/question/11235928

7 0
2 years ago
Create a PHP page that contains an array of at least 20 movie titles or book titles (your choice). The HTML page should have an
ella [17]

Answer:

This is the code

Explanation:

<html>

<form method="POST" action="welcome.php">

label for="usname">username:</label><br>

<input type="text" id="usname" name="usname"><br>

<label for="movietitles">Movietitles</label><br>

<textarea type="text" id="movetitle" name="movietitles">Please enter movie titles</textarea>

<input type="submit">

</form>

</html>

<?php

$Movietitles= array("bland", "decoy","Mademan", "Rich", "bland", "decoy","Mademan", "Rich", "bland", "decoy","Mademan", "Rich" , "bland", "decoy","Mademan", "Rich, "decoy","Mademan", "Rich", "Adapt" );

$username= $_POST['username'];

if (!empty($_POST['username'])) {

$username = $_POST['username'];

echo "Welcome";

}

?>

The post method HTTP request is used to send the data from the form to the Welcome.php file above so that it validates/tests that username has been entered using the php if statement and if it is not empty(entered username) php "echos" welcome to the screen.

5 0
3 years ago
Security controls are measures taken to protect systems from attacks on the integrity, confidentiality, and availability of the
Delvig [45]

Answer:

The correct option is D: Administrative controls

Explanation:

Administrative controls are also known as work practice controls and involves changes in the procedure of work such as rules, schedules, policies, training etc, with the intention of cutting down to the barest minimum incidence, duration, and the graveness of exposure to situations or chemical that constitute a hazard. Drug screening test would be to ensure that the employee is fit to work and does not form a hazard and thus is an administrative control.

4 0
3 years ago
Whoever helps me with these questions i will help them with the same number of questions in any subject: 1. As the operations ma
mezya [45]
I'm going have to go with with 1.b and 2.d hope this helps and I don't need help right now.
6 0
3 years ago
Hey does anyone think nervegear would be possible? (Just asking)
Vlada [557]

Answer:

Depends

Explanation:

Technology is not advanced yet, so building a fully functional nerve gear is difficult. It could be possible in a few years though.

7 0
3 years ago
Read 2 more answers
Other questions:
  • Side mirror using convex mirror or concave mirror?​
    5·2 answers
  • When you copy text, the selected text is copied from the original location and placed on the
    9·1 answer
  • . A program that can run more than one thread at once is called:
    9·1 answer
  • What are the four types of technical drawing?​
    9·1 answer
  • As a general rule, the number of bullet points on a slide should not exceed _____. a.2 b.4 c.8 d.10
    9·1 answer
  • Which branch of science helps avoid or minimize stress-related injuries at workplace?
    14·2 answers
  • Initialized the variable with the value 0
    11·2 answers
  • ¿Qué son las tecnologías modernas?
    6·1 answer
  • What is a key differentiator of Conversational Artificial Intelligence (AI)
    11·1 answer
  • Why would you use a computer's secondary memory?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!