Solved

A Programmer Notices That the Following Code Snippet Uses the Same

Question 52

Multiple Choice

A programmer notices that the following code snippet uses the same algorithm for computing cost after taxes, but with different variables, in the two places as shown below, and in several other places in the program. What could be done to improve the program?
Final double TAXRATE1 = 10;
Final double TAXRATE2 = 5.5;
Double subtotal = price * (1 + TAXRATE1) / 100;
Double total = subtotal + shipping * (1 + TAXRATE2) / 100;


A) Declare the tax rates as variables, not constants.
B) Define a method that looks up tax rates for goods and shipping charges.
C) Define a method that prompts the user for an amount and a tax rate, then returns the total amount including the tax.
D) Define a method that computes the cost after taxes from arguments for the cost before taxes and the tax rate.

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions

Unlock this Answer For Free Now!

View this answer and more for free by performing one of the following actions

qr-code

Scan the QR code to install the App and get 2 free unlocks

upload documents

Unlock quizzes for free by uploading documents