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
computer hardware without software is useless while computer software without hardware is meaningless. explain what do you under
Rainbow [258]

Answer:

That the software is useless

Explanation:

6 0
3 years ago
AD and BC are equal perpendiculars to a line segment AB (see figure). Show that CD
Simora [160]
Show the picture to answer the question
7 0
3 years ago
The natural functions of Earth seem all _____ in one way or another.
Sonja [21]
Would it be Similar ?
4 0
3 years ago
In which of the following situations is having a good credit score important?
Triss [41]
<span>The correct answer is to be able to loan from banks. Having a good credit score, impacts one's approval for bank loans. It will enable a person to have a higher chance of getting his or her loan, approved by the banks, than those who have low credit scores. </span>
8 0
3 years ago
Stella is a bank executive. She is preparing a spreadsheet on the loan repayment schedules of customers. Which function can she
den301095 [7]

Answer: The function Stella can use to calculate the periodic payments of a loan is:

The Excel PMT function or NPER function.

Explanation: 1. The Excel PMT function is a financial function that returns the periodic payment for a loan.

2. The NPER function to figure out payments for a loan, given the loan amount, number of periods, and interest rate.

7 0
3 years ago
Other questions:
  • "The fact that we could create and manipulate an Account object without knowing its implementation details is called"
    9·1 answer
  • "To take advantage of these developments in the digital world, new approaches, concepts,instruments, and methods are needed, whi
    8·1 answer
  • What should you do before cleaning the top of a storage battery and rinsing it with fresh water?
    12·1 answer
  • Application means to
    5·1 answer
  • Often used in connection with a business
    6·1 answer
  • Technological uncertainty:
    15·1 answer
  • Define a function below, sum_numeric_vals, which takes a single dictionary as a parameter. The dictionary has only strings for k
    12·1 answer
  • You would like to enter a formula that subtracts the data in cell B4 from the total of cells B2 and B3. What should the formula
    10·1 answer
  • Type the correct answer in the box. Spell all words correctly.
    7·2 answers
  • Lattice-based access controls use a two-dimensional matrix to assign authorizations. What are the two dimensions and what are th
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!