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
Which guideline should you follow when selecting the font for a presentation
Sladkaya [172]
My school requires us to use Arial and double space it but we have to use font size 30 for title and 24 for the paragraphs.
3 0
3 years ago
I have wings, I am able to fly, I‘m not a bird yet I soar high in the sky. What am I?
yanalaym [24]
You are a butterfly!!
6 0
3 years ago
Read 2 more answers
7. Explain the steps for formatting a shape ?
alisha [4.7K]

Answer:

To begin, select the shapes you want to format. To select more than one, press and hold the Shift key. When you select one or more shapes, a new Drawing Tools tab appears. Here, you can select Shape Fill to fill the selected shapes with a solid color, gradient, texture, or picture.

Explanation:

3 0
2 years ago
A ____________________ can be used to hierarchically represent a classification for a given set of objects or documents. A. taxo
neonofarm [45]

Answer:

A. taxonomy

Explanation:

A taxonomy can be used to hierarchically represent a classification for a given set of objects or documents.

3 0
3 years ago
Hi, please help me, solution.​
loris [4]

Answer:

error: incompatible types

Explanation:

Given

The attached code

Required

The output

Variable "a" is declared as float

While p is declared as a pointer to an integer variable

An error of incompatible types will be returned on line 3, <em>int *p = a;</em>

Because the variables are not the same.

To assign a to p*, we have to use type casting.

Hence, (b) is correct

5 0
3 years ago
Other questions:
  • Computers are said to use binary data because all computer data is simply a series of Os and 1s.
    10·1 answer
  • The command for creating a PivotTable is found in the <br> tab.
    7·1 answer
  • ​For complex models, analysts can choose computer-based modeling tools that use _____, which includes standard shapes and symbol
    10·1 answer
  • Suppose you are given a data set consisting of nominal attributes, such as color, which takes values such as red, blue, green et
    9·1 answer
  • What would be a reason for using a workstation rather than a personal computer?
    7·1 answer
  • This type of software works with end users, application software, and computer hardware to handle the majority of technical deta
    12·1 answer
  • I need more friends plz talk with me
    6·2 answers
  • Question #1 Mutiple Select Which features are important when you plan a program? Select 4 options. Knowing what you want the pro
    5·1 answer
  • Explain the concept of conditional formatting​
    9·1 answer
  • What is a word processor write any five important features of word processor?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!