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.