answer.
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
Dovator
2 months ago
14

Write a method printShampooInstructions(), with int parameter numCycles, and void return type. If numCycles is less than 1, prin

t "Too few.". If more than 4, print "Too many.". Else, print "N: Lather and rinse." numCycles times, where N is the cycle number, followed by "Done.". End with a newline. Example output with input 2: 1: Lather and rinse. 2: Lather and rinse. Done. Hint: Declare and use a loop variable. import java.util.Scanner; public class ShampooMethod { /* Your solution goes here */ public static void main (String [] args) { Scanner scnr = new Scanner(System.in); int userCycles; userCycles = scnr.nextInt(); printShampooInstructions(userCycles); } }
Computers and Technology
1 answer:
Rzqust [1K]2 months ago
4 0

Answer:

import java.util.Scanner;

public class nu3 {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       System.out.println("Input the number of cycles");

       int numCycles = in.nextInt();

       //Invoke the method

       printShampooInstructions(numCycles);

   }

   public static void printShampooInstructions(int numCycles){

                if (numCycles<1){

              System.out.println("Not enough");

          }

          if (numCycles>4){

              System.out.println("Too many");

          }

          else {

              for (int i = 1; i <= numCycles; i++) {

                  System.out.println( numCycles+ ": Lather and rinse");

                  numCycles--;

              }

              System.out.println("Done");

          }

   }

}

Explanation:

This solution involves the use of Java programming language.

The printShampooInstructions() method is highlighted in the answer section.

A complete program is provided, prompting the user to enter a value for the number of cycles, subsequently calling the method and passing that value in.

The structure of the code operates through if... else statements to manage various potential inputs for Number of cycles.

A loop is employed in the Else Section to print the number of cycles in a decrementing manner.

You might be interested in
You work in the educational software industry. Your boss asks you to give a brief lecture to other employees about the digital d
Harlamova29_29 [1022]
Joe mama is the most extraordinary person on the planet.
5 0
2 months ago
Read 2 more answers
For any element in keysList with a value greater than 50, print the corresponding value in itemsList, followed by a space. Ex: I
ivann1987 [1066]

Answer:

import java.util.Scanner;  //as referenced in the prompt.

public class ArraysKeyValue {  //as mentioned in the prompt.

public static void main (String [] args) {  //as stated in the prompt.

final int SIZE_LIST = 4; //as indicated in the prompt.

int[] keysList = new int[SIZE_LIST]; //as specified in the prompt.

int[] itemsList = new int[SIZE_LIST]; //as outlined in the prompt.

int i; //as identified in the prompt.

keysList[0] = 13; //as mentioned in the prompt.                                

keysList[1] = 47; //as stated in the prompt.

keysList[2] = 71; //as described in the prompt.

keysList[3] = 59; //as referenced in the prompt.

itemsList[0] = 12; //as mentioned in the prompt.

itemsList[1] = 36; //as stated in the prompt.

itemsList[2] = 72; //as specified in the prompt.

itemsList[3] = 54;//as indicated in the prompt.

// additional line needed to finalize the solution is as follows--

for(i=0;i<(keysList.length);i++) //Loop to access each element of keysList array variable.

    {// open for loop braces

        if(keysList[i]>50) // compare the values of keysList array variable with 50.

        System.out.println(itemsList[i]); // print the value

   }// close for loop braces.

}//  close main function braces.

} //close class braces.

Output:

72

54

Explanation:

In the resolution section--

  1. A single loop is engaged that iterates from 0 to (size-1) of the 'keyslist' array.
  2. The 'if' statement checks whether the 'keyslist' array's element exceeds 50 or not.
  3. If it does, the respective 'i' indexed item from the item_list array is printed as well, which corresponds to the higher value of the keyslist array element.

5 0
1 month ago
The PictureBook class is a subclass of the Book class that has one additional attribute: a String variable named illustrator tha
Amiraneli [1052]

Response:

s

Clarification:

x

8 0
3 months ago
Other questions:
  • An author is preparing to send their book to a publisher as an email attachment. The file on their computer is 1000 bytes. When
    6·1 answer
  • Strlen("seven"); what is the output?
    14·1 answer
  • Write a statement that reads a floating point value from standard input into temperature. Assume that temperature. has already b
    6·1 answer
  • Assume that getPlayer2Move works as specified, regardless of what you wrote in part (a) . You must use getPlayer1Move and getPla
    14·1 answer
  • To finish creating a design for the webpage, use one shape to cut away part of the other. Create a 700 pixel by 700 pixel square
    10·1 answer
  • #Write a function called random_marks. random_marks should #take three parameters, all integers. It should return a #string. # #
    10·1 answer
  • Write a function named firstLast2 that takes as input an array of integers and an integer that specifies how many entries are in
    14·1 answer
  • Java Programming home &gt; 1.14: zylab training: Interleaved input/output Н zyBooks catalog Try submitting it for grading (click
    6·1 answer
  • The maximum number of times the decrease key operation performed in Dijkstra's algorithm will be equal to ___________
    14·1 answer
  • A company has deployed four 48-port access layer switches to a switch block. For redundancy each access layer switch will connec
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!