1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
kirill115 [55]
3 years ago
5

Complete method 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
Computers and Technology
1 answer:
Sladkaya [172]3 years ago
6 0

Answer:

The complete method in cpp is given below.  

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;  

}  

The program implementing the above method is given below.  

#include <iostream>  

using namespace std;  

//method declared  

void printPopcornTime(int bagOunces);  

int main() {  

//variable declared  

int bagOunces;  

//variable initialized  

bagOunces = 10;  

//method called which accepts integer parameter  

printPopcornTime(bagOunces);  

//program ends  

return 0;  

}  

//method defined  

void printPopcornTime(int bagOunces)  

{  

//output displayed based on the value of the variable  

if(bagOunces<2)  

cout<<"Too small"<<endl;  

else if(bagOunces>10)  

cout<<"Too large"<<endl;  

else  

cout<<6*bagOunces << " seconds"<<endl;  

}  

OUTPUT1  

60 seconds  

Explanation:

Program explanation is given below.

1. The method, printPopcornTime(), having return type as void and accepting an integer parameter, bagOunces, is declared as shown.  

void printPopcornTime(int bagOunces);  

2. Method declaration only contains return type, method name and parameters taken by the method, if any.  

3. Method definition consists of the complete method. All the code to be written inside the method is also included in its definition.  

4. The method definition for printPopcornTime() is shown in the beginning.  

5. The value of the integer parameter is tested using multiple if-else statements.  

6. The output is based on the value of the parameter. The output is ends with a newline inserted by endl.

7. The main() method has a return type integer and takes no parameters. The main() method is declared and defined together unlike as shown for the other method, printPopcornTime().  

8. The integer variable, bagOunces, is declared and initialized inside main().  

9. This variable is passed as parameter to the printPopcornTime() method and calling the method.  

printPopcornTime(bagOunces);  

10. The program ends with a return statement.  

11. All the results are shown based on the different values of the variable, bagOunces. The original output is obtained when the value of bagOunces is 10.  

12. If the value of bagOunces is 1, the message displayed is shown.  

OUTPUT2  

Too small  

13. If the value of bagOunces is 11, the message displayed is shown.  

OUTPUT3  

Too large  

You might be interested in
Which of the following statements is the least abstraction of the world wide web
Sliva [168]
<span>Documents, images and other data you can access by providing a uniform Resource Locator. URL - the Web Address

I hope this helps. You didn't give me the choices to from.  </span>
8 0
3 years ago
Read 2 more answers
What is a Caesar cipher? As part of your answer demonstrate encrypting the plaintext messages: CS IS COOL with a caesar cipher.
sweet [91]

Answer:

A Caesar Cipher is a basic encryption type.

Explanation:

Its implementation is very easy and straightforward. It uses a one-to-one of characters in a character set. The input needed is the plain-text message and the encryption number.

For example, using the character set A-Z, encrypting the text CS IS COOL using the key of 3 generates FV LV FRRO. What has been done here is to take each character in the plain-text message and move it by "encryption number steps" in the character set.

8 0
3 years ago
What is the output produced from the following statements? System.out.println("\"Quotes\""); System.out.println("Slashes \\//");
jekas [21]

Answer:

"Quotes"

Slashes \//

How '"confounding' "\" it is!

Explanation:

The question above is testing your knowledge of  the "\" escape sequence, This escape sequence is used to introduce special formatting to the output of the System.out.print function in Java.

It can be used to introduce a new line \n

It can also be used to introduce a tab indentation \t

As in the question above it is used to introduce double quotes "" in this case \"

Also as we see the question above it can still be used to place backlashes to an output in this case we use two backlashes \\. The first is the escape sequence, the second \ gets printed out.

3 0
3 years ago
PLZ HELP IM IN A HURRY Select all that apply.
chubhunter [2.5K]

Answer:

                                                       

Explanation:

<h3>                             </h3>
8 0
3 years ago
Assume that name and age have been declared suitably for storing names (like "Abdullah", "Alexandra" and "Zoe") and ages respect
Irina18 [472]

Answer:

import java.util.Scanner;

public class num2 {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       System.out.println("Enter Name");

       String name = in.next();

       System.out.println("Enter Age");

       int age = in.nextInt();

       System.out.println("The age of "+name +" is "+age);

   }

}

Explanation:

Java programming language is used to write the code.

The scanner class is used to prompt and receive values for name and age which are stored in the appropriate variables.

The key idea here is using string concatenation in the output statement in order to print the desired output

3 0
3 years ago
Other questions:
  • g Create a program that reads a list of states from an input file, puts them in order, and displays the sorted list to the user.
    15·1 answer
  • Tornado Alley is located in the middle of the United States, extending from Texas up through the Dakotas. The above statement is
    14·1 answer
  • Anyone help me with number 41.
    12·1 answer
  • In Florida no fault insurance is optional for owners of a vehicle
    6·1 answer
  • You are the IT administrator for a small corporate network. Recently, you added a web server that runs services that need to be
    12·1 answer
  • rray testGrades contains NUM_VALS test scores. Write a for loop that sets sumExtra to the total extra credit received. Full cred
    5·1 answer
  • Write a program which asks the user to enter N numbers. The program will print out their average. Try your program with the foll
    11·1 answer
  • A(n) ____ uses the communication interface to request resources, and the server responds to these requests.
    15·1 answer
  • Listed here are a few camera angles and their images.
    10·1 answer
  • Submit your newsletter that includes the following: two or three columns a title at least three graphics, but not more than six
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!