103k views
5 votes
Complete function 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.1 #include 2 using namespace std; 34 void PrintPopcornTime (int bagOunces)5 6 Your solution goes here 10 int main) 7891011 PrintPopcornTime(7) 12 13 return 0 14

1 Answer

2 votes

Answer:

#include <iostream>

using namespace std;

void PrintPopcornTime (int bagOunces){

if (bagOunces < 2){

cout << "Too small"<<endl;

}

else if (bagOunces > 10){

cout << "Too large"<<endl;

}

else{

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

}

}

int main(){

PrintPopcornTime(7);

return 0;

}

Step-by-step explanation:

Create a function called PrintPopcornTime that takes one parameter, bagOunces

Check the bagOunces using if-else structure. If it is smaller than 2, print "Too small". If it is greater than 10, print "Too large". Otherwise, calculate and print 6*bagOunces followed by " seconds".

Call the function in the main function with parameter 7. Since 7 is not smaller than 2 or not greater than 10, "42 seconds" will be printed.

User Jaxon
by
4.9k points