subject

Write a method printShampooInstructions(), with int parameter numCycles, and void return type. If numCycles is less than 1, print "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 for numCycles = 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 printShampooInstructions(int numCycles){

if(numCycles < 1){
System. out. println("Too few.");
}
else if(numCycles > 4){
System. out. println("Too many.");
}
else{
for(int i = 1; i <= numCycles; i++){
System. out. println(i + ": Lather and rinse.");
}
System. out. println("Done.");
}
}
/ Your solution end here /
public static void main (String [] args) {
printShampooInstructions(2);

return;
}
}

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 17:10
3. consider the following class definitions: class smart class supersmart: public smart { { public: public: void print() const; void print() const; void set(int, int); void set(int, int, int); int sum(); int manipulate(); smart(); supersmart(); smart(int, int); supersmart(int, int, int); private: private: int x; int z; int y; int secret(); }; }; . which private members, if any, of smart are public members of supersmart? a. which members, functions, and/or data of the class smart are directly accessible in class supersmart?
Answers: 2
question
Computers and Technology, 23.06.2019 12:00
Using the list, you can select the number of photos that will appear on each slide. a. theme b. frame shape c. pictures in album d. picture layout
Answers: 1
question
Computers and Technology, 23.06.2019 17:30
What are the most commonly found items in the trash according to the municipal solid waste report?
Answers: 1
question
Computers and Technology, 24.06.2019 16:50
How many types of string types does python support?
Answers: 1
You know the right answer?
Write a method printShampooInstructions(), with int parameter numCycles, and void return type. If nu...
Questions
Questions on the website: 13722362