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
Consider two different implementations, M1 and M2, of the same instruction set. There are three classes of instructions (A, B, a
Margaret [11]

Explanation:

A.)

we have two machines M1 and M2

cpi stands for clocks per instruction.

to get cpi for machine 1:

= we multiply frequencies with their corresponding M1 cycles and add everything up

50/100 x 1 = 0.5

20/100 x 2 = 0.4

30/100 x 3 = 0.9

CPI for M1 = 0.5 + 0.4 + 0.9 = 1.8

We find CPI for machine 2

we use the same formula we used for 1 above

50/100 x 2 = 1

20/100 x 3 = 0.6

30/100 x 4 = 1.2

CPI for m2 =  1 + 0.6 + 1.2 = 2.8

B.)

CPU execution time for m1 and m2

this is calculated by using the formula;

I * CPI/clock cycle time

execution time for A:

= I * 1.8/60X10⁶

= I x 30 nsec

execution time b:

I x 2.8/80x10⁶

= I x 35 nsec

6 0
2 years ago
What four things does steering control involve?
Dafna1 [17]

Answer:

putting your hands one the wheel, putting the car in gear, putting your foot on the brakes when you need to, and watch for cars when you're driving. hope it helps

Explanation:

7 0
3 years ago
The CPU's control unit retrieves the next instruction in a sequence of program instructions from main memory in the ______ stage
Varvara68 [4.7K]

Answer:

A. Fetch.

Explanation:

The fetch-decode-execute process of simply the fetch-execute process of the CPU are stages the CPU follow to process information and the switch state or shutdown.

The stages of this process is implied in its name, that is, the stages are fetch, decide and execute.

The fetch stage retrieves the next instruction from the memory.

The decode stage converts the clear text instruction set to electronic signals and transfer it to the appropriate registers.

The execute stage is the action carried out in the arithmetic logic unit.

5 0
3 years ago
To prepare a list of the ten largest cities in Asia, Luke should most likely use data to
kakasveta [241]
He should find answers about the population size hope this helps 
5 0
3 years ago
Read 2 more answers
Write a program that plays the popular scissor-rockpaper game. (A scissor can cut a paper, a rock can knock a scissor, and a pap
kolbaska11 [484]

Answer:

import random

computer = random.randint(0, 2)

user = int(input("scissor (0), rock (1), paper (2): "))

if computer == 0:

   if user == 0:

       print("The computer is scissor. You are scissor too. It is a draw")

   elif user == 1:

       print("The computer is scissor. You are rock. You won")

   elif user == 2:

       print("The computer is scissor. You are paper. Computer won")

elif computer == 1:

   if user == 0:

       print("The computer is rock. You are scissor. Computer won")

   elif user == 1:

       print("The computer is rock. You are rock too. It is a draw")

   elif user == 2:

       print("The computer is rock. You are paper. You won")

elif computer == 2:

   if user == 0:

       print("The computer is paper. You are scissor. You won")

   elif user == 1:

       print("The computer is paper. You are rock. Computer won")

   elif user == 2:

       print("The computer is paper. You are paper too. It is a draw")

Explanation:

*The code is in Python.

Import the random to be able to generate number number

Generate a random number between 0 and 2 (inclusive) using randint() method and set it to the computer variable

Ask the user to enter a number and set it to the user variable

Check the value of computer the computer variable:

If it is 0, check the value of user variable. If user is 0, it is a draw. If user is 1, user wins. If user is 2, computer wins

If it is 1, check the value of user variable. If user is 0, computer wins. If user is 1, it is a draw. If user is 2, user wins

If it is 2, check the value of user variable. If user is 0, user wins. If user is 1, computer wins. If user is 2, it is a draw

8 0
2 years ago
Other questions:
  • Ron is creating building blocks in Word. How can he make the building blocks that he created available?
    11·2 answers
  • Jason works as a financial investment advisor. He collects financial data from clients, processes the data online to calculate t
    9·1 answer
  • Timing circuits are a crucial component of VLSI chips. Here’s a simple model of such a timing circuit. Consider a complete balan
    10·1 answer
  • Need Help !!! Please
    8·1 answer
  • &gt;&gt;&gt; import math &gt;&gt;&gt; print(math.Pi) 3.141592653589793 &gt;&gt;&gt; def print_volume(): print ("What is the radi
    12·1 answer
  • David Doe is a network administrator for the ABC Company. David is passed over for promotion three times. He is quite vocal in h
    14·1 answer
  • To view the results of a query, open it by pressing and holding or right-clicking the query in the navigation pane and tapping o
    10·1 answer
  • Write function d2x() that takes as input a nonnegative integer n (in the standard decimal representation) and an integer x betwe
    14·1 answer
  • Write an if statement that assigns 0.2 to commission if sales is greater than or equal to 10000.
    11·1 answer
  • Do you think EA sports should add more tape jobs to the game? (Game is nhl22)
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!