Ask Question
30 September, 22:44

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. 1 October, 01:45
    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?
Get 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 & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers