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
I can’t wait Till Miya’s anniversary skin To be released on september 21st
dezoksy [38]

Answer:

no u

Explanation:

no need

3 0
3 years ago
PLEASE HELP ILL GIVE BRAINLIEST
jeyben [28]

Answer:

text labels and different

Explanation:

4 0
3 years ago
What is a space flight that doesn’t complete a full orbit referred to as?
Vikentia [17]

Answer:

A flight that does not reach space is still sometimes called suborbital, but is not a 'suborbital spaceflight'. Usually a rocket is used, but experimental sub-orbital spaceflight has also been achieved with a space gun.

Explanation:

3 0
3 years ago
#include using namespace std; double CelsiusToKelvin(double valueCelsius) { double valueKelvin; valueKelvin = valueCelsius + 273
otez555 [7]

Answer:

//Below are the function which the user needs to add on the place of the "Your solution goes here".

double KelvinToCelsius(double valueKelvin)

{

   double valueCelsius;

   valueCelsius = valueKelvin - 273.15;

   return valueCelsius;

}

Explanation:

Missing information : The above question is missing which states to define one function which name is "KelvinToCelsius" and which takes one argument and changes the kelvin value into Celsius value. One header file syntax is also missing on the above question.

  • The above question wants to add a function to the place of the "Your solution goes here" and the work of the function is defined on the question.
  • So the above-defined function is used to return the value of Celsius if the user passes the value of kelvin.
  • The above-question also holds one function which takes the value of kelvin and returned Celsius, which returns value "283.15".
  • So if a user passes "283.15 for the kelvin value, then he got 10 which is defined as Celsius value on the question".
3 0
3 years ago
Which of these is an example of an online workspace?
irakobra [83]
A website that hosts a companies documents
8 0
2 years ago
Other questions:
  • How do you ask someone for help?
    6·1 answer
  • A client contacted you to request your help in researching and supplying the hardware necessary to implement a SOHO solution at
    9·1 answer
  • I analyze data, as a consultant, for companies making important business decisions. In order to get my point across, which of th
    11·1 answer
  • Review the two e-mail messages below for their adherence to the guidelines for professional e-mail correspondence you have learn
    6·1 answer
  • Analyze the following code. Which of the following statements is correct?
    9·1 answer
  • A USB device used to transfer photos from the memory card to a hard drive is called a _____.
    5·2 answers
  • PrimeFactorization.java: Write a program that begins by reading in a series of positive integers on a single line of input and t
    12·1 answer
  • Create a function called is_list_empty that takes a single argument of type list. Your function should return True if the list i
    7·1 answer
  • The most widely used computer device​
    6·2 answers
  • Define a function Output Value() that takes two integer parameters and outputs the sum of all negative integers starting with th
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!