Using C++, 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 = 7:42 seconds1 #include 2 using namespace std; 34 void PrintPopcornTime(int bagOunces) { 56 /* Your solution goes here */ 78 } 9 int main() { 10 int userOunces; cin >> userOunces; 11 PrintPopcornTime12 13 return 0; 14 }

Respuesta :

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 << 6 * bagOunces <<" seconds" << endl;

}

int main()

{

   int userOunces;

   cin >> userOunces;

   PrintPopcornTime(userOunces);

   return 0;

}

Explanation:

Inside the function PrintPopcornTime, check the parameter bagOunces using if structure. Depending on the value of bagOunces, print the required information.

Inside the main, ask the user for the userOunces. Call the PrintPopcornTime function with the userOunces.

ACCESS MORE