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
MrRa [10]
2 years ago
9

Complete function PrintPopcornTime(), with int parameter bagOunces, and void return type. If bagOunces is less than 3, print "To

o small". If greater than 10, print "Too large". Otherwise, compute and print 6 * bagOunces followed by " seconds". End with a newline. Example output for ounces = 7:42 seconds#include void PrintPopcornTime(int bagOunces) {}int main(void) {int userOunces;scanf("%d", &userOunces);PrintPopcornTime(userOunces);return 0;}2. 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 with input 2:1: Lather and rinse.2: Lather and rinse.Done. Hint: Declare and use a loop variable.#include /* Your solution goes here */int main(void) {int userCycles;scanf("%d", &userCycles);PrintShampooInstructions(userCycles);return 0;}

Computers and Technology
1 answer:
SVETLANKA909090 [29]2 years ago
6 0

Answer:

<h2>Function 1:</h2>

#include <stdio.h> //for using input output functions

// start of the function PrintPopcornTime body having integer variable //bagOunces as parameter

void PrintPopcornTime(int bagOunces){

if (bagOunces < 3){ //if value of bagOunces is less than 3

 printf("Too small"); //displays Too small message in output

 printf("\n"); } //prints a new line

//the following else if part will execute when the above IF condition evaluates to //false and the value of bagOunces is greater than 10

else if (bagOunces > 10){

    printf("Too large"); //displays the message:  Too large in output

    printf("\n"); //prints a new line }

/*the following else  part will execute when the above If and else if conditions evaluate to false and the value of bagOunces is neither less than 3 nor greater than 10 */

else {

/* The following three commented statements can be used to store the value of bagOunces * 6 into result variable and then print statement to print the value of result. The other option is to use one print statement printf("%d",bagOunces * 6) instead */

    //int result;

    //result = bagOunces * 6;

    //printf("%d",result);

 printf("%d",bagOunces * 6);  /multiplies value of bagOunces  to 6

 printf(" seconds");

// seconds is followed with the value of bagOunces * 6

 printf("\n"); }} //prints a new line

int main(){ //start of main() function body

int userOunces; //declares integer variable userOunces

scanf("%d", &userOunces); //reads input value of userOunces

PrintPopcornTime(userOunces);

//calls PrintPopcornTime function passing the value in userOunces

return 0; }

Explanation:

<h2>Function 2:  </h2>

#include <stdio.h> //header file to use input output functions

// start of the function PrintShampooInstructions body having integer variable numCycles as parameter

void PrintShampooInstructions(int numCycles){

if(numCycles < 1){

//if conditions checks value of numCycles is less than 1 or not

printf("Too few."); //prints Too few in output if the above condition is true

printf("\n"); } //prints a new line

//else if part is executed when the if condition is false and else if  checks //value of numCycles is greater than 4 or not

else if(numCycles > 4){

//prints Too many in output if the above condition is true

printf("Too many.");

printf("\n"); } //prints a new line

//else part is executed when the if and else if conditions are false

else{

//prints "N: Lather and rinse." numCycles times, where N is the cycle //number, followed by Done

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

printf("%d",N);

printf(": Lather and rinse. \n");}

printf("Done.");

printf("\n");} }

int main() //start of the main() function body

{    int userCycles; //declares integer variable userCycles

   scanf("%d", &userCycles); //reads the input value into userCycles

   PrintShampooInstructions(userCycles);

//calls PrintShampooInstructions function passing the value in userCycles

   return 0;}

I will explain the for loop used in PrintShampooInstructions() function. The loop has a variableN  which is initialized to 1. The loop checks if the value of N is less than or equal to the value of numCycles. Lets say the value of numCycles = 2. So the condition evaluates to true as N<numCycles  which means 1<2. So the program control enters the body of loop. The loop body has following statements. printf("%d",N); prints the value of N followed by

printf(": Lather and rinse. \n"); which is followed by printf("Done.");

So at first iteration:

printf("%d",N); prints 1 as the value of N is 1

printf(": Lather and rinse. \n");  prints : Lather and rinse and prints a new line \n.

As a whole this line is printed on the screen:

1: Lather and rinse.

Then the value of N is incremented by 1. So N becomes 2 i.e. N = 2.

Now at second iteration:

The loop checks if the value of N is less than or equal to the value of numCycles. We know that the value of numCycles = 2. So the condition evaluates to true as N<numCycles  which means 2=2. So the program control enters the body of loop.

printf("Done."); prints Done after the above two lines.

printf("%d",N); prints 2 as the value of N is 2

printf(": Lather and rinse. \n");  prints : Lather and rinse and prints a new line \n.

As a whole this line is printed on the screen:

2: Lather and rinse.

Then the value of N is incremented by 1. So N becomes 2 i.e. N = 3.

The loop again checks if the value of N is less than or equal to the value of numCycles. We know that the value of numCycles = 2. So the condition evaluates to false as N<numCycles  which means 3>2. So the loop breaks.

Now the next statement is:

printf("Done."); which prints Done on the screen.

So as a whole the following output is displayed on the screen:

1: Lather and rinse.

2: Lather and rinse.

Done.

The programs along with their outputs are attached.

You might be interested in
What is a wireless network that provides communication over a short distance that is intended for use with devices that are owne
andrew11 [14]

Answer: personal area network

Explanation:

it can connect personal devices to make network, the personal network are phone,laptop,printer and soon in order to communicate.

3 0
2 years ago
Read 2 more answers
It's safe to download files from the internet if u perform regular Windows security updates, that is all u need to protect your
Vlad1618 [11]

Answer

TRUE

Explanation

A computer virus is a self-replicating program which are malicious and are designed to infect and gain control over a computer without the owner's knowledge.

To protect your computer from viruses especially when downloading files from the internet, it is advisable for one to perform regular windows security updates. This is because because windows have malware definitions to its windows defender and security essential utilities.

7 0
3 years ago
Read 2 more answers
A Chief Security Officer (CSO) has asked a technician to devise a solution that can detect unauthorized execution privileges fro
VikaD [51]

A solution which would best meet the CSO's requirements is: B. Sandboxing.

<h3>What is a sandbox?</h3>

A sandbox can be defined as an isolated environment in a computer system or on a network that is designed and developed to mimic end user operating system (OS) and environments, so as to detect unauthorized execution privileges from the operating system (OS).

In cybersecurity, sandboxing is typically used to safely execute suspicious code and data files without causing any harm to the host device or network. Also, sandboxing can work in conjunction with proxies or unified threat management (UTM).

Read more on sandboxing here: brainly.com/question/25883753

8 0
2 years ago
Should there be an agency in charge of the Internet? How would business, government, and education be impacted if the Internet w
aksik [14]
I believe the government should not be able to regulate or control the internet. The internet is a place to express and exchange new ideas. And when an agency or government starts to regulate the internet, they can prevent from view certain content.

There is something called net neutrality. Its definition can be found on Google, "the principle that Internet service providers should enable access to all content and applications regardless of the source, and without favoring or blocking particular products or websites." - Google

What that means is, that internet service providers (ISP's) should provide all content without discrimination. For example. There is two ISP's. ISP A and ISP B. ISP B does not practice net neutrality. So, when a customer has ISP B's service, he/she cannot view content from ISP A. Or whatever company or websites ISP B does not want you to view. On the contrary, ISP A practice net neutrality. ISP A provides all content for its customers. Even if ISP A doesn't like ISP B or any websites, it still allows their customers to view that content. 

I support for new neutrality. And so should you.
3 0
3 years ago
Citation placeholders allow you to mark positions in your document for citations without stopping to create and insert a new cit
Alecsey [184]
I believe the answer to this is True
8 0
2 years ago
Other questions:
  • How does making a phone call differ when using: A public phone A cell phone
    6·1 answer
  • How would this requirement be implemented?
    12·1 answer
  • The next generation ip version and successor to ipv4 is called what? ipv5 ipv6 iana ssl
    13·1 answer
  • If you were to design a range of athletic shoes for various sports activities, what key factors would you consider during the de
    11·1 answer
  • After conducting interviews with several bad candidates, Althea, a manager at Langrover Inc. interviewed a candidate who was bet
    15·1 answer
  • Create a class called StockTester that has the following fucntionality. a. Create a main method with an ArrayList named dataStoc
    9·1 answer
  • Which type of programming language translates one line of code at a time and then executes it before moving to the next line?
    5·2 answers
  • Differentiate between patent and copyright.
    6·2 answers
  • Which one did I buy the iPhone 13 or the Samsung S22 Ultra?
    14·2 answers
  • What do conditions do for programs?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!