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
kow [346]
3 years ago
8

Write a method printshampoolnstructions0, 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 with input 2:
1: Lather and rinse.
2: Lather and rinse. Done. Hint: Declare and use a loop variable

İmport java.util.Scanner;
public class ShampooMethod ( 5 Your solution goes here
public static void main (String [1 args) (
Scanner senr new Scanner(System.in);
int userCycles; 10
userCycles scnr.nextInt): printShaspooInstructions(userCycles);
Computers and Technology
1 answer:
fredd [130]3 years ago
3 0

Answer:

// Scanner import to allow user enter input

import java.util.Scanner;

// Class definition

public class ShampooMethod {

   // The beginning of program execution which is the main method

   public static void main(String args[]) {

       //Scanner object to receive user input via the keyboard

       Scanner scan = new Scanner(System.in);

       //The received input is assigned to userCycles variable

       int userCycles = scan.nextInt();

       //printShampooInstructions method is called with userCycles as argument

       printShampooInstructions(userCycles);

   }

   

   // The printShampooInstructions is defined

   public static void printShampooInstructions(int numCycles){

       // Check if numCycles is less than 1 and output "too few"

       if(numCycles < 1){

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

       } else if (numCycles > 4){

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

       } else{

          // for-loop which repeat for the range of numCycles and display the instruction

           for(int i = 1; i <= numCycles; i++){

               if(i == numCycles){

                   System.out.println(i + ":" + " Lather and rinse. Done.");

               } else{

                   System.out.println(i + ":" + " Lather and rinse.");

               }

              }

           }

       }

   }

Explanation:

The code has been commented to be explanatory. First the Scanner class is imported, then the class is defined. Then, the main method is also declared. Inside the main method, the user input is accepted and assigned to userCycles. The userCycles is passed as argument to the printShampooInstructions.

The printShampooInstructions is created with a parameter of numCycle and void return type. If the numberCycle is less than 1; "Too few..." is outputted. If numCycle is greater than 4; "Too many" is displayed. Else the shampoo instuction "Lather and rinse" is repeated for the numCycle. During the last repetition, "Done" is attached to the shampoo instruction.

You might be interested in
10. Question<br> What are the drawbacks of purchasing something online? Check all that apply.
max2010maxim [7]

Explanation:

1) the quality of purchased good may be low

2) there might me fraud and cheaters

3) it might be risky

4) we may not get our orders on time

7 0
2 years ago
Create a program in Matlab that prints the numbers from 1-100.
Burka [1]

Answer:

numbers = 1:1:100;

for num=numbers

remainder3 = rem(num,3);

remainder5 = rem(num,5);

 

if remainder3==0

disp("Yee")

else

if remainder3 == 0 && remainder5 == 0

disp ("Yee-Haw")

else

if remainder5==0

disp("Haw")

else

disp("Not a multiple of 5 or 4")

end

end

end  

end

Explanation:

  • Initialize the numbers variable from 1 to 100.
  • Loop through the all the numbers and find their remainders.
  • Check if a number is multiple of 5, 3 or both and display the message accordingly.
4 0
3 years ago
What is computer hardware / software​
Pavel [41]

Answer: <u>Computer hardware is any physical device used in or with your machine, like for example, a mouse, or a keyboard.</u> Computer software is a collection of programming code installed on your computer's hard drive it can process billions of data and inputs through this.

Hope this helps!

5 0
2 years ago
um I'm new and I just sign up like right now and brainly says I've reached my daily limit for my questions why?
Natalija [7]

Answer:

Im not sure why but maybe you can find a way to contact the people who own it and see if they know because that hasn't happened to me. How many questions have you asked

Explanation:

7 0
3 years ago
Write a java program as follows Write a method called powOfTwo that takes an integer as parameter, computes, and outputs it’s sq
Kisachek [45]

Answer:

public static int powOfTwo(int input) {

 return input*input;

}

You will have to call this method in main
for printing it, write

System.out.println(powOfTwo(your number));

in public static void main(str[]args) {

}

8 0
2 years ago
Other questions:
  • Data mining must usestatistics to analyze data.<br> True<br> False
    12·1 answer
  • What are the basic tools for coding HTML manually?
    10·2 answers
  • What is the name used for the camera s view from a single position?
    9·1 answer
  • The _ are the devices that allow a computer system to communicate and interact with the outside world as well as store informati
    11·1 answer
  • The _____ handles the instructions for your computer to start up before the operating system is loaded.
    10·1 answer
  • To determine the average of a range of numbers, click the ____ in the formula bar, then click average.
    13·1 answer
  • Software on your computer is taking a long time to load. What could help solve this problem?
    5·1 answer
  • Approximately how long did it take, in minutes, for the body to return to normal after the intake of water.
    11·1 answer
  • Write a function that dynamically allocates an array of integers. The function should accept an integer argument indicating the
    8·1 answer
  • WHICH PROGRAMMING LANGUAGES ARE THE BEST FOR PROGRAMMING?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!