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