232k views
0 votes
Complete method printpopcorntime(), with int parameter bagounces, and void return type. if bagounces is less than 3, 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:

2 Answers

2 votes

Answer:

/* Your solution goes here */

if(bagOunces < 3) {

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

}

else if ( bagOunces > 10) {

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

}

else {

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

}

System.out.print("");

Step-by-step explanation:

/* Explanation */

if(bagOunces < 3) { //if bagounces is less than 3

System.out.println("Too small"); //print "too small".

}

else if ( bagOunces > 10) { //if greater than 10

System.out.println("Too large"); //print "too large".

}

else { //otherwise

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

} //compute and print 6 * bagounces followed by "seconds".

System.out.print(""); //end with a newline.

Hope this helps a bit with how I translated the code.

User Systemhalted
by
8.2k points
4 votes
public void printpopcorntime(int bagounces) { if (bagounces < 3) { System.out.println("too small"); } else if (bagounces > 10) { System.out.println("too large"); } else { System.out.println( 6*bagounces +"seconds"); } System.out.println("\\"); }
User Chetan Ankola
by
8.5k points