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
Greeley [361]
3 years 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:
iogann1982 [59]3 years 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("Enter number of cycles");

       int numCycles = in.nextInt();

       //Call the method

       printShampooInstructions(numCycles);

   }

   public static void printShampooInstructions(int numCycles){

                if (numCycles<1){

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

          }

          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 is solved using Java programming language

The method printShampooInstructions() is in bold in the answer section

I have also provided a complete program that request user to enter value for number of cycles, calls the method and passes that value to it

The logic here is using if .... else statements to handle the different possible values of Number of cycles.

In the Else Section a loop is used to decrementally print the number of cycles

You might be interested in
Read three integers from user input without a prompt. Then, print the product of those integers. Ex: If input is 2 3 5, output i
trapecia [35]

Answer:

num1=2

num2=3

num3=5

num1= int(num1)

num2= int(num2)

num3= int(num3)

pro = num1*num2*num3

print(pro)

Explanation:

This is very close to a correct answer in easy code and easy to read, I was not able to put the answer in without the proper indentation alignment the way I would present this. So please adjust to your requirements for the indentation.

3 0
2 years ago
To enhance the readability of your document, select a layout that aligns text ________.
Vilka [71]

Answer:

b. only at the left margin.

Explanation:

It's the most widely accepted layout. MLA format, which is used in most professional settings, aligns the body to the left. Though, the answer may be different depending on the language.

5 0
2 years ago
Read 2 more answers
Face book requires you to change your password regularly<br> a. TRUE<br> b. FALSE
Irina-Kira [14]
The answer is for this question is false
8 0
3 years ago
Paano nakatutulong ang teknolohiyang pangkomunikasyon sa pangangalap ng impormsyon
Makovka662 [10]

Answer:

Yes correct. Absolutely breathtaking. You should create poetry with your writing skills.

6 0
3 years ago
Two technicians are discussing using a lift to raise a vehicle. Technician A says to be sure the lift pads on the lift are conta
lianna [129]
Its B no doubt
cuz ik how to do this i took classes for this so ik im right ight
6 0
3 years ago
Read 2 more answers
Other questions:
  • Stock ____ firms trade financial securities between a buyer and a seller.
    11·1 answer
  • 9.6 Code Practice: Question 1
    9·1 answer
  • Operational feasibility, which refers to user acceptance and support, as well as management acceptance and support, is also know
    9·1 answer
  • Which is an example of a tertiary source?
    13·1 answer
  • Recall that TCP can be enhanced with SSL to provide process-to-process security services, including encryption. Does SSL operate
    7·1 answer
  • If you have a database of books in the library and you would like to find all books published after January 1, 2008, what criter
    7·1 answer
  • Features of action files​
    15·1 answer
  • Who is responsible for developing the physical background for the characters by creating buildings, landscapes, and interiors?
    14·1 answer
  • Power point is hardware or software​
    12·2 answers
  • Plz help
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!