answer.
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
Leviafan [203]
2 years ago
3

Write a function PrintShampooInstructions(), with int parameter numCycles, and void return type. If numCycles is less than 1, pr

int "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 for numCycles = 2:
1: Lather and rinse.
2: Lather and rinse.
Done.

Hint: Define and use a loop variable.

So, this is what I have done.
#include
using namespace std;
void PrintShampooInstructions( int numCycles ) {
if (numCycles < 1) {
cout << "Too few." << endl ;
}
if (numCycles > 4 ) {
cout << "Too many." << endl ;
}
else {
int i = 0 ;
int N = 0 ;
for ( i = N ; i < numCycles ; ++i) {
cout << "i: Lather and rinse." << endl ;
cout << "Done." << endl ;
}
}
}
return ;
}
int main() {
PrintShampooInstructions(2);

return 0;
}

Computers and Technology
1 answer:
Mazyrski [523]2 years ago
7 0

Answer:

See explaination

Explanation:

Source code below.

#include <iostream>

using namespace std;

// <STUDENT CODE>

// Define the function PrintShampooInstructions().

void PrintShampooInstructions(int numCycles)

{

// Display "Too few." if the value

// of numCycles is less than 1.

if (numCycles < 1)

{

cout << "Too few." << endl;

}

// Display "Too many." if the value

// of numCycles is greater than 4.

else if (numCycles > 4)

{

cout << "Too many." << endl;

}

// Otherwise, do the following:

else

{

// Define the loop variable.

int N = 1;

// Start the loop from 1 to numCycles.

for (N = 1; N <= numCycles; N++)

{

// Print the value of N followed by "Lather and rinse".

cout << N << ": Lather and rinse." << endl;

}

// Print "Done." followed by newline.

cout << "Done." << endl;

}

}

// Define the main() function.

int main()

{

PrintShampooInstructions(2);

return 0;

}

Please kindly check attachment for sample output and program screen shot.

You might be interested in
Assume that the population of Mexico is 128 million and that the population increases 1.01 percent annually. Assume that the pop
horrorfan [7]

Answer:

//Define class

public class Main {

 //define main method

 public static void main(String[] args)  

 {

   //declare and initialize the double type variable to 128

   double mexico = 128;

   //declare and initialize the double type variable to 323

   double us = 323;

   //declare and initialize the integer type variable to 0  

   int yr = 0;

   //set the while loop to check which is greater

   while (mexico < us)  

   {

     //increment in the variable by 1

     yr++;

     //initialize in the variables acc. to the percentage

     mexico *= 1.0101;

     us *= 0.9985;

   }

   //print the following results

   System.out.println("Population of the Mexico will be exceed the population U.S. in " + yr + " years");

   System.out.println("Population of the Mexico will be " + mexico + " million");

   System.out.println("and population of the U.S. will be " + us + " million");

 }

}

<u>Output</u>:

Population of the Mexico will be exceed the population U.S. in81 years

Population of the Mexico will be 288.88435953355025 million

and population of the U.S. will be 286.0198193927948 million

Explanation:

<u>Following are the description of the program</u>.

  • Firstly, we define the class 'Main' and inside it, we define the main method.
  • Then, declare two double data type variables which are 'mexico' and 'us' and initialize in it to 128 and 323.
  • Declare integer data type variable 'yr' and initialize in it to 0.
  • Set the while loop and pass the condition to check that the variable 'mexico' is less than the variable 'us' then, increment in the variable 'yr' by 1 and multiply the variables 'us' and 'mexico' by the following percentage.
  • Finally, print the following results with the message.
6 0
2 years ago
Days of the week are represented as three-letter strings ("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"). Write a javaScript f
dmitriy555 [2]

Answer:

function getDay(s, k){

var weekDays = ["Mon","Tue","Wed","Thu","Fri","Sat","Sun"];

var index=weekDays.findIndex(function(weekDay){return weekDay==s;});

return weekDays[(index+k)%7];

}

Explanation:

//this functions receive the next parameters:

//s which is the day of the week

//k the number of days after s week day

function getDay(s, k){

var weekDays = ["Mon","Tue","Wed","Thu","Fri","Sat","Sun"];

//variable index is the index in list weekDays of s

var index=weekDays.findIndex(function(weekDay){return weekDay==s;});

//use module operator % to get the remainder of the division (index+k)/7

//return the string value of the day

return weekDays[(index+k)%7];

}

3 0
2 years ago
FTP requires confirmation that a file was successfully transmitted to a client, but it has no built-in mechanism to track this i
Sholpan [36]

Answer:

Transmission Control Protocol (TCP)

Explanation:

FTP: FTP stand for File Transfer Protocol. It is an internet protocol for transferring files between computers on a computer network over TCP/IP connections. It is based on client server architecture in which a client asks for a file and the server (local or remote) sends it. FTP uses TCP to ensure all the data packets are transmitted correctly to the proper destination.

Transmission Control Protocol: It is a protocol used in the Transport Layer of the TCP/IP model. The basic role of this layer is to ensure end-to-end delivery of data from the source to the destination. TCP is a connection oriented protocol that works with the Internet Protocol and provides ordered, guaranteed and error free delivery of data from source to destination. This is how application programs communicate and exchange data through an IP network. It is connection oriented protocol means connection between client and server is setup before data transmission. At source host TCP divides streams of bytes in segments. Then it allocates sequence number to each segment. At destination end it reorders the delivered segments. Then it sends an acknowledgment  to sender as a signal that the correct segments have been received. TCP also employs error detection that ensure reliability. TCP also manages flow control and congestion control to avoid data packets loss or delay and to ensure that a sender does not send packets faster than the receiver can receive.

4 0
2 years ago
What infrastructure model provides access to shared computing resources over a network, often the internet?
Goshia [24]
Cloud computing infrastructure model provides access to shared computing resources over a network, often the internet. The cloud computing infrastructure is a virtual infrastructure composed of hardware and software components <span>needed to support the </span>computing<span> requirements of a </span>cloud computing model.And the cloud computing model is <span>the delivery of computing services (servers, storage, databases, networking, software, analytics and more) over the Internet .</span> 
7 0
2 years ago
What language(s) must be used to display a bare-minimum web page?
Reil [10]

Answer: Hyper Text Markup Language (HTML)

Explanation:  

Computers use language to communicate, just like people do and the way that computers communicate with the internet is through a language that is called Hyper Text Markup Language/ HTML

Hyper Text is the process of linking objects to each other, so that when one object is clicked the linking object can be viewed. Hyper Text Markup Language was created by Tim burners in 1990


8 0
2 years ago
Read 2 more answers
Other questions:
  • Nick won a $1,000 lottery prize. He can't decide what he should spend the money on. For some time now, he has been planning to b
    5·1 answer
  • Which sector provides scope for multimedia designers?
    10·1 answer
  • The spreadsheet below shows the names years in office, and number of terms for five US presidents
    7·2 answers
  • Desmond works in Power, Structural, and Technical Systems. He would most likely be employed by
    5·2 answers
  • Assume the existence of a Window class with a function getWidth that returns the width of the window. Define a derived class Win
    15·1 answer
  • Describe a situation involving making a copy of a computer program or an entertainment file of some sort for which you think it
    7·1 answer
  • Database management systems are expected to handle binary relationships but not unary and ternary relationships.'
    7·1 answer
  • Stan’s assignment is to print a three-dimensional image on a piece of paper. Which printing technique should he use?
    14·2 answers
  • Write a MATLAB function named average_of_scores_with_drops The function will have two inputs and two return values. The first in
    11·1 answer
  • A video game character can face toward one of four directions: north, south, east, and west. Each direction is stored in memory
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!