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
SVETLANKA909090 [29]
3 years ago
14

Define function print_popcorn_time() with parameter bag_ounces. If bag_ounces is less than 3, print "Too small". If greater than

10, print "Too large". Otherwise, compute and print 6 * bag_ounces followed by "seconds". End with a newline.
Computers and Technology
2 answers:
yawa3891 [41]3 years ago
8 0

Answer:

void print_popcorn_time(int bag_ounces){

   if(bag_ounces < 3){

       cout<<"Too small"<<endl;

   }else if(bag_ounces > 10){

       cout<<"Too large"<<endl;

   }else{

       cout<<(6 * bag_ounces)<<"seconds"<<endl;

   }

}

Explanation:

The function is the block of the statement which performs the special task.

For checking the condition in the program, the if-else statement is used.

It can check the condition one or two but if we want to check the more than two different conditions then the continuous if-else statement is used.

syntax of continuous if else:

if(condition){

statement;

}else if(condition)

statement;

}else{

statement;

}

In the question, there are three conditions;

1. bag_ounces is less than 3

2. bag_ounces greater than 10

3. else part.

we put the condition in the above if-else statement and print the corresponding message.

erastova [34]3 years ago
5 0

Answer:

def print_popcorn_time(bag_ounces):

   if bag_ounces < 3:

       print("Too small")

   elif bag_ounces > 10:

        print("Too large")

   else:

        bag_ounces = bag_ounces * 6

        print(bag_ounces, "seconds")

Explanation:

def print_popcorn_time(bag_ounces): #fed function

   if bag_ounces < 3:  #1st if statement

       print("Too small") #print function

   elif bag_ounces > 10: #else if

        print("Too large") #print than print

   else:  #else:

        bag_ounces = bag_ounces * 6 #do work

        print(bag_ounces, "seconds") #print

You might be interested in
Why is my computer fans making weird noises?
sattari [20]

Answer:

The biggest culprit for excess noise in computers Computer internal devices all generate "heat."  Most computers manufacturer add temperature controller fans on important internal devise or locations.  These will spin faster when "hot" temperatures are detected.  With the fans, there are usually "ventilation holes" needed to push this hot "air" out.  Unfortunately, these holes let in dust and "other debris' into the fans, thus making them "spin" harder and faster. This is normal. You might want to take your computer to your school's office and ask them about your. computer. I think I have a solution below but I am not sure it will work.

Check to make sure that your computer is set to use all of your speakers. Navigate to the Control Panel, and double-click Sounds And Audio Devices. If you change this setting, click Apply, OK, and then OK again to exit the Sounds And Audio Devices Properties dialog box.

Hope this answer helped you have a good day.  :)

3 0
2 years ago
Read 2 more answers
2 WAp to input the radius and print<br> the area of circle
daser333 [38]
<h3>Program:-</h3>

\tt r=float(input("Enter\:the\:value\:for\:radius\:of\:circle"))

\tt x=3.14*\:r**2

\tt print("Area\:of\:Circle=\{x\}")

<h3>Sample run:-</h3>

\tt r=3

\tt Area\:of\:the\:circle=28.26

5 0
2 years ago
2. Consider a 2 GHz processor where two important programs, A and B, take one second each to execute. Each program has a CPI of
allsm [11]

Answer:

program A runs in 1 sec in the original processor and 0.88 sec in the new processor.

So, the new processor out-perform the original processor on program A.

Program B runs in 1 sec in the original processor and 1.12 sec in the new processor.

So, the original processor is better then the new processor for program B.

Explanation:

Finding number of instructions in A and B using time taken by the original processor :

The clock speed of the original processor is 2 GHz.

which means each clock takes, 1/clockspeed

= 1 / 2GH = 0.5ns

Now, the CPI for this processor is 1.5 for both programs A and B. therefore each instruction takes 1.5 clock cycles.

Let's say there are n instructions in each program.

therefore time taken to execute n instructions

= n * CPI * cycletime = n * 1.5 * 0.5ns

from the question, each program takes 1 sec to execute in the original processor.

therefore

n * 1.5 * 0.5ns = 1sec

n = 1.3333 * 10^9

So, number of instructions in each program is 1.3333 * 10^9

the new processor :

The cycle time for the new processor is 0.6 ns.

Time taken by program A = time taken to execute n instructions

=  n * CPI * cycletime

= 1.3333 * 10^9 * 1.1 * 0.6ns

= 0.88 sec

Time taken by program B = time taken to execute n instructions

= n * CPI * cycletime

= 1.3333 * 10^9 * 1.4 * 0.6

= 1.12 sec

Now, program A runs in 1 sec in the original processor and 0.88 sec in the new processor.

So, the new processor out-perform the original processor on program A.

Program B runs in 1 sec in the original processor and 1.12 sec in the new processor.

So, the original processor is better then the new processor for program B.

5 0
2 years ago
Write a program to read a list of exam scores given as integer percentages in the range 0-100. Display the total number of grade
Tju [1.3M]

Answer:

import java.util.Scanner;

public class Program

{

  public static void main(String [] Args)

  {

      int totalAGrades = 0, totalBGrades = 0, totalCGrades = 0, totalDGrades = 0, totalFGrades = 0, counter=0,maximum = 0, minimum = 9999, num, total = 0,smallest = 0,largest = 0;

       Scanner in = new Scanner(System.in);

       System.out.println("Enter exam percentage: ");

       System.out.println("Enter a negative examScore: ");

       int examScore = in.nextInt();

       while(examScore > 0)

       {

         counter++;

         if(examScore < 0){          

             break;}  

         else if(examScore > maximum){      

              maximum = examScore;}

         else if(examScore < minimum)   {  

              minimum = examScore;}

         

          total = total + examScore;  

     

          if(examScore <= 50 && examScore>0)

              smallest = examScore;

              if(examScore > 90 && examScore <=100)

              largest = examScore;

         

      if(examScore>=90 && examScore<=100)

          totalAGrades++;

      else if(examScore>=80 && examScore<=89)

          totalBGrades++;

      else if(examScore>=70 && examScore<=79)

          totalCGrades++;

      else if(examScore>=60 && examScore<=69)

          totalDGrades++;

      else if(examScore>=0 && examScore<=59)

          totalFGrades++;

      examScore = in.nextInt();

     

   }

      System.out.println("Total number of scores is = " + counter );

      System.out.println("Total Number of each Letter grade : " + counter);

      System.out.println("Percentage of total for each letter grade : ");

          System.out.println("Total number of A grades = "+ totalAGrades);

          System.out.println("Total number of B grades = "+ totalBGrades);

          System.out.println("Total number of C grades = "+ totalCGrades);

          System.out.println("Total number of D grades = "+ totalDGrades);

          System.out.println("Total number of F grades = "+ totalFGrades);

     

      System.out.println("Lowest exam Score is :"+smallest);

      System.out.println("Highest exam Score is :"+largest);

      System.out.println("Average exam Score = "+ (total / counter));

  }

}  

Explanation:

  • Get the exam information from user as input and run a while loop until examScore is greater than zero.
  • Use conditional statement to check the scores of students and increment the relevant grade accordingly.
  • Finally display all the information including grades and scores.
3 0
3 years ago
In a class hierarchy,
kondor19780726 [428]

Answer:

The correct answer to the following question will be Option D.

Explanation:

  • A collection of nested title scopes are defined by the class hierarchy, even though a collection of nested methodologies as well as blocks see in an everything else.
  • From the all, the lexical role characterizes the connection between certain scopes of names - if method d would be decided to declare somewhere within procedure c, therefore the namespace within the namespace of c would be nested.
  • The more common classes in such a family hierarchy were near the peak of the tree as well as more specific classes are towards the edges.

Other choices have no connection with the given situation. So Option D seems to be the right response.

4 0
2 years ago
Other questions:
  • Write a set of pseudocode instructions to feed a pet, using at least five steps?<br><br> Thank you!!
    6·1 answer
  • 1- Which of the following is the java keyword used to declare a class?
    5·2 answers
  • Which model allows you to make subsystems in parallel?
    12·1 answer
  • What is the function of the NOS? Select all that apply.
    5·2 answers
  • Effective scrum masters apply which coaching behavior
    5·1 answer
  • Is Filmora 9 or Final Cut Pro Better for personal use?
    12·1 answer
  • What are acenders? What are decenders?
    10·2 answers
  • How do you modify WordArt? Give specific details and steps<br><br> NEED THIS ASAP
    9·1 answer
  • When you use the predict step in the IPDE process you
    8·1 answer
  • you are investigating the use of website and url content filtering to prevent users from visiting certain websites. which benefi
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!