Solved

A Programmer Notices That the Following Code Snippet Uses the Same

Question 57

Multiple Choice

A programmer notices that the following code snippet uses the same algorithm for computing interest earned, but with different variables, in the two places shown below and in several other places in the program. What could be done to improve the program?
Final double RATE1 = 10;
Final double RATE2 = 5.5;
Double interest = investment * RATE1 / 100;
) . .
Balance = balance + balance * RATE2 / 100;


A) Declare the rates as variables, not constants.
B) Define a method that looks up interest rates.
C) Define a method that prompts the user for an amount and a rate of interest, then returns the interest earned.
D) Define a method that computes the interest earned from an amount and a rate of interest.

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