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
arlik [135]
3 years ago
12

For the given program, how many print statements will execute? public static void printShippingCharge(double weight) { if((weigh

t > 0.0) && (weight <= 10.0)){ System.out.println(weight * 0.75); } else if((weight > 10.0) && (weight <= 15.0)) { System.out.println(itemWeight * 0.85); } else if((weight > 15.0) && (weight <= 20.0)) { System.out.println(itemWeight * 0.95); } } public static void main(String args[]) { printShippingCharge(18); printShippingCharge(6); printShippingCharge(25); }
Computers and Technology
1 answer:
Step2247 [10]3 years ago
4 0

CORRECT QUESTION:

For the given program, how many print statements will execute?

public static void printShippingCharge(double weight) { if((weight > 0.0) && (weight <= 10.0)){ System.out.println(weight * 0.75); }

else if((weight > 10.0) && (weight <= 15.0)) { System.out.println(weight * 0.85); }

else if((weight > 15.0) && (weight <= 20.0)) { System.out.println(weight * 0.95); } }

public static void main(String args[]) {

printShippingCharge(18);

printShippingCharge(6);

printShippingCharge(25); }

Answer:

Two of the print statements will output values

Explanation:

These two calls to the printShippingCharge are the ones that will output values: printShippingCharge(18); and printShippingCharge(6);

The first if statement is true when the value of weight is 6 (weight > 0.0) && (weight <= 10.0)

The Third if statement  is true when weight is 18 (weight > 15.0) && (weight <= 20.0)

NOTE: That I made correction to the variable weight. The question isn't consistent with the variable name. It used weight and itemWeight at different points this will lead to a compiller error

You might be interested in
What allows a programmer to write code quickly and efficiently for an action that must be repeated?
hodyreva [135]

Answer:

A. an iteration

8 0
3 years ago
Using C++, Write a full class definition for a class named Acc1, containing no constructors, functions, or data members (i.e., a
alexgriva [62]
Hi!

Okay, so - 

To make a C++ class, we have to use the keyword <em>class </em>followed by the class name, and a pair of curly braces which will be our <em>class body</em><em>. </em>

Our class body is what holds all of our constructors, functions, and data members. 

So, to write a completely empty class - we would just have to simply write:

<em>class Acc1 
</em>{

};

<em />Note -

All classes must end with a semi colon! This is just a standard rule we follow since it was how C++ has been defined. If you were to leave the semi colon out, you would get a compiler error! =)
4 0
3 years ago
Read 2 more answers
Que es la fisiconometria?
Anni [7]

Answer:

it is a field of study concerned with the theory and technique of psychological measurement.

or

Medición de las funciones mentales en general y de las características psíquicas de los individuos en particular.

Explanation:

8 0
3 years ago
Sherry’s science teacher requires the use of an open access database . Which of the following meets the requirements
cestrela7 [59]
<h2>Answer:</h2>

<u>The correct option is </u><u>(D) Google</u>

<h2>Explanation:</h2>

Open access database refers to free, unrestricted online access to research outputs such as journal articles and books. Open Access content is open to all, with no access fees. Since Google provides its services free of cost and it is open to all of the people across the world therefore it can be considered as an Open Access database.

6 0
4 years ago
Write an application that accepts up to 20 Strings, or fewer if the user enters the terminating value ZZZ. Store each String in
notsponge [240]

Answer:

count = 20

i = 0

short_strings = []

long_strings = []

while(i<count):

   s = input("Enter a string: ")

   

   if s == "ZZZ":

       break

   

   if len(s) <= 10:

       short_strings.append(s)

   elif len(s) >= 11:

       long_strings.append(s)

   

   i += 1

choice = input("Enter the type of list to display [short/long] ")

if choice == "short":

   if len(short_strings) == 0:

       print("The list is empty.")

   else:

       print(short_strings)

else:

   if len(long_strings) == 0:

       print("The list is empty.")

   else:

       print(long_strings)

Explanation:

*The code is in Python.

Initialize the count, i, short_strings, and long_strings

Create a while loop that iterates 20 times.

Inside the loop:

Ask the user to enter a string. If the string is "ZZZ", stop the loop. If the length of the string is smaller than or equal to 10, add it to the short_strings. If the length of the string is greater than or equal to 11, add it to the long_strings. Increment the value of i by 1.

When the loop is done:

Ask the user to enter the list type to display.

If the user enters "short", print the short list. Otherwise, print the long_strings. Also, if the length of the  chosen string is equal to 0, print that the list is empty.

3 0
4 years ago
Other questions:
  • *Could someone please help me with this***
    5·1 answer
  • A collection of related files that serves as a foundation for retrieving information is a: byte
    12·1 answer
  • The popularity of blogging is an example of _____. the public producing the media the public regulating the media both of the ab
    15·2 answers
  • Simple geometry can compute the height of an object from the the object's shadow length and shadow angle using the formula: tan(
    12·1 answer
  • What is data and imformation?​
    6·1 answer
  • Which among the following if absent, a computer is not complete.
    6·2 answers
  • It is where your cpu (processor) is installed
    10·2 answers
  • Is climate change a man-made problem or a natural occurrence ? Why or why not ?
    8·1 answer
  • Multiple Choice: Circle the letter that corresponds to the correct answer.
    12·1 answer
  • Your friends are having difficulties with their computer setups. Can you suggest a way to help each friend?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!