106k views
5 votes
A store applies a 15 percent service charge on all items with a price of at least$150. No service charge is otherwise applicable. Which of the following DOES NOTcorrectly compute the service charge?Select one:a.double serviceCharge = 0;if (cost >= 150){serviceCharge = 0.15 * cost;}b.double serviceCharge = 0.15 * cost;if (cost <= 150){serviceCharge = 0;}c.double serviceCharge;if (cost < 150){serviceCharge = 0;}else{serviceCharge = 0.15 * cost;}d.double serviceCharge = 15;if (cost >= 150){serviceCharge = 0.15 * cost;}else{serviceCharge = 0;}

1 Answer

6 votes

Answer:

The answer is "Option b"

Step-by-step explanation:

In the given choices, in "option b" a double type variable "serviceCharge" is defined that multiply cost value by 0.15, in the next step, if the conditional statement is used, that checks cost value is less then equal to 150. If this condition is true, it will change the variable value, which is equal to 0, that's why this option is wrong because in this option the "serviceCharge" variable value is always 0, and other options are correct.

User TrentWoodbury
by
6.0k points