Ask Question

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

+3
Answers (1)
  1. 3 April, 20:56
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers