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, 22.06.2019 01:20
What is the full meaning of rfid in computer
Answers: 2
question
Computers and Technology, 22.06.2019 13:00
Why the bear has a slunky tail determine the meaning of the word slunk in the story
Answers: 1
question
Computers and Technology, 24.06.2019 13:30
Type the correct answer in the box. spell all words correctly. what is the default margin width on all four sides of a document? by default, the document has a margin on all four sides.
Answers: 1
question
Computers and Technology, 24.06.2019 16:50
7.23 main lab 7 - online shopping cart background this main lab extends the earlier prep lab "online shopping cart part 1". (you should save this as a separate project from the earlier prep lab). you will create an on-line shopping cart like you might use for your on-line purchases. the goal is to become comfortable with setting up classes and using objects. requirements this lab can be done individually or as pair programming. expanded itemtopurchase class (15 points) extend the itemtopurchase class as follows. we will not do unit testing in this lab so we will not be giving you the names of the member functions. create good ones on your own. create a parameterized constructor to assign item name, item description, item price, and item quantity (default values of "none" for name and description, and 0 for price and quantity). additional public member functions set an item description get an item description print the cost of an item - outputs the item name followed by the quantity, price, and subtotal (see example) print the description of an item - outputs the item name and description (see example) additional private data members a string for the description of the item. example output of the function which prints the cost of an item: bottled water 10 @ $1.50 = $15.00 example output of the function which prints the item description:
Answers: 1
You know the right answer?
Write a method printShampooInstructions(), with int parameter numCycles, and void return type. If nu...
Questions
question
Mathematics, 19.11.2020 17:40
question
Mathematics, 19.11.2020 17:40
question
Geography, 19.11.2020 17:40
question
Mathematics, 19.11.2020 17:40
question
Mathematics, 19.11.2020 17:40
question
Mathematics, 19.11.2020 17:40
question
Biology, 19.11.2020 17:40
question
Mathematics, 19.11.2020 17:40