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
kirill115 [55]
3 years ago
5

Complete method printPopcornTime(), with int parameter bagOunces, and void return type. If bagOunces is less than 2, print "Too

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
Computers and Technology
1 answer:
Sladkaya [172]3 years ago
6 0

Answer:

The complete method in cpp is given below.  

void printPopcornTime(int bagOunces)  

{  

if(bagOunces<2)  

cout<<"Too small"<<endl;  

else if(bagOunces>10)  

cout<<"Too large"<<endl;  

else  

cout<<6*bagOunces << " seconds"<<endl;  

}  

The program implementing the above method is given below.  

#include <iostream>  

using namespace std;  

//method declared  

void printPopcornTime(int bagOunces);  

int main() {  

//variable declared  

int bagOunces;  

//variable initialized  

bagOunces = 10;  

//method called which accepts integer parameter  

printPopcornTime(bagOunces);  

//program ends  

return 0;  

}  

//method defined  

void printPopcornTime(int bagOunces)  

{  

//output displayed based on the value of the variable  

if(bagOunces<2)  

cout<<"Too small"<<endl;  

else if(bagOunces>10)  

cout<<"Too large"<<endl;  

else  

cout<<6*bagOunces << " seconds"<<endl;  

}  

OUTPUT1  

60 seconds  

Explanation:

Program explanation is given below.

1. The method, printPopcornTime(), having return type as void and accepting an integer parameter, bagOunces, is declared as shown.  

void printPopcornTime(int bagOunces);  

2. Method declaration only contains return type, method name and parameters taken by the method, if any.  

3. Method definition consists of the complete method. All the code to be written inside the method is also included in its definition.  

4. The method definition for printPopcornTime() is shown in the beginning.  

5. The value of the integer parameter is tested using multiple if-else statements.  

6. The output is based on the value of the parameter. The output is ends with a newline inserted by endl.

7. The main() method has a return type integer and takes no parameters. The main() method is declared and defined together unlike as shown for the other method, printPopcornTime().  

8. The integer variable, bagOunces, is declared and initialized inside main().  

9. This variable is passed as parameter to the printPopcornTime() method and calling the method.  

printPopcornTime(bagOunces);  

10. The program ends with a return statement.  

11. All the results are shown based on the different values of the variable, bagOunces. The original output is obtained when the value of bagOunces is 10.  

12. If the value of bagOunces is 1, the message displayed is shown.  

OUTPUT2  

Too small  

13. If the value of bagOunces is 11, the message displayed is shown.  

OUTPUT3  

Too large  

You might be interested in
For a Know Simple query, a Fully Meets rating can be given if the result does not display the answer, but it is at the very top
tekilochka [14]

Answer:

For a Know Simple query, a Fully Meets rating can be given if the result does not display the answer, but it is at the very top of the landing page.

B) False

Explanation:

  • A know simple query is special form of a know query. The query which are intended to know something like what is the length of pitch of a cricket ground?
  • A know simple query is such a know query that can be described in very little amount of words.
  • A know simple query would only get the fully meet ratings if the result shown has the result in a special result block or it is shown upfront. You don't need to open a link to get the answer in such scenario.

6 0
3 years ago
Which of the following is one of the first two levels of formatting in a Word document?
Dafna1 [17]

Explanation:

Paragraph Formatting.

5 0
3 years ago
how do you make a 3d project im a huge programer and I need to know how to do it or all I do will be considered retro gaming
aivan3 [116]
Bacon, go to the bacon! WORSHIP THE BACON!!!!!!!
6 0
3 years ago
What is repeating a set of instructions called? But not repetition.
zlopas [31]

Answer:

Iteration.

Explanation:

A process wherein a set of instructions or structures are repeated in a sequence a specified number of times or until a condition is met. When the first set of instructions is executed again, it is called an iteration.

7 0
3 years ago
Read 2 more answers
I can't find my friend, brazenhmc. Can anyone help me?
aliina [53]
I can help you with anything right here and always like the other guy said
4 0
3 years ago
Read 2 more answers
Other questions:
  • The only requirement of __________ is that the sender must provide some mechanism whereby the receiver can opt out of future ema
    14·1 answer
  • ____ deals with ensuring that data is protected against unauthorized access, and if the data are accessed by an authorized user,
    10·1 answer
  • Suppose the file is sent continuously as one big message. how long does it take to send the file, assuming it is sent continuous
    15·1 answer
  • Which of the following statements is not true? Group of answer choices
    9·1 answer
  • A security utility program that scans the system for small programs that interfere with how a computer functions are _____ utili
    13·1 answer
  • One form of online vandalism is ____ operations, which interfere with or disrupt systems to protest the operations, policies, or
    9·2 answers
  • Send link for a qc or paddle
    11·1 answer
  • Debate whether social networking is harmful or helpful to society.
    5·1 answer
  • Meaning of mesh topology​
    15·1 answer
  • Compared to using a command line, an advantage to using an operating system that employs a gui is ________.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!