Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a function PrintShampooInstructions(), with int parameter numCycles, and v

ID: 3827896 • Letter: W

Question

Write a function PrintShampooInstructions(), 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 for numCycles = 2:

c++

_______________________________________

#include <iostream>
using namespace std;

/* Your solution goes here */

int main() {
PrintShampooInstructions(2);

return 0;
}

Explanation / Answer

#include <iostream>
using namespace std;

void PrintShampooInstructions(int numCycles)
{
if(numCycles < 1)
{
cout << "Too few." << endl;
}
else if (numCycles > 4)
{
cout << "Too many." << endl;
}
else
{
for(int i = 1; i <= numCycles; i++)
{
cout << i << ": Lather and rinse." << endl;
}
cout << "Done." << endl;
}
}

int main() {
PrintShampooInstructions(2);
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote