Write a method printshampooinstructions() with int parameter numcycles and void return type

Write a method printshampooinstructions() with int parameter numcycles and return type void

Write a method printshampooinstructions() with int parameter numcycles and return type void


Answer

import java.util.Scanner;

public class ShampooMethod {

    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.");
        }
    }

    public static void main(String[] args) {
        Scanner scnr = new Scanner(System.in);
        int userCycles;

        userCycles = scnr.nextInt();
        printShampooInstructions(userCycles);
    }
}

Related Posts
C Programming – Define stubs for the functions called by the below main().

Programming in C – Define stubs for the functions called by main() below.

Write the printItem() method for the base class. Sample output for below program:

Write the printItem() method for the base class. Sample output for the program below:

Complete the method definition to output the hours given minutes. Output for sample program: 3.5

Complete the method definition to output the given times to minutes. Output to sample program: 3.5

Write a method printshampooinstructions() with int parameter numcycles and void return type

Write a method printshampooinstructions() with int parameter numcycles and return type void

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *