Ask Question
27 April, 04:50

Complete method print PopcornTime (), with int parameter bag Ounces, and void return type. If bag Ounces is less than 2, print "Too small". If greater than 10, print "Too large". Otherwise, compute and print 6 * bag Ounces followed by "seconds". End with a newline. Example output for ounces = 7

+5
Answers (1)
  1. 27 April, 08:36
    0
    public static void PopcornTime (double bagOunces) {

    if (bagOunces<2) {

    System. out. println ("Too small");

    }

    else if (bagOunces>10) {

    System. out. println ("Too large");

    }

    else{

    System. out. println ((6*bagOunces) + " seconds");

    }

    }

    Explanation:

    A Complete Java code with a call to the method PopcornTime () is given below

    public class TestClock {

    public static void main (String[] args) {

    //Calling the method

    PopcornTime (2);

    }

    public static void PopcornTime (double bagOunces) {

    if (bagOunces<2) {

    System. out. println ("Too small");

    }

    else if (bagOunces>10) {

    System. out. println ("Too large");

    }

    else{

    System. out. println ((6*bagOunces) + " seconds");

    }

    }

    }

    The key logic in this code is the use of if/else if/else statements to check the different possible values of of bagOunces.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Complete method print PopcornTime (), with int parameter bag Ounces, and void return type. If bag Ounces is less than 2, print "Too small". ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers