JAVA QUESTION How do I fix this Checkstyle error in eclipse? \"20.0 is a magic n
ID: 3708128 • Letter: J
Question
JAVA QUESTION
How do I fix this Checkstyle error in eclipse?
"20.0 is a magic number"
I want to re-write the the entire code shown by:
1) Define a class constant with a meaningful name to hold that value
2) now use the name of the constant in your code instead of the hard-coded value
/ round to 2 decimal number if (myMembership && total.compareTo (new BigDecimal(20.0 final BigDecimal discountRatenew BigDecimal(0.0015/ 100); final BigDecimal discountAmo final BigDecimal discountTotal- total.subtract(discountAmount); total discountTotal; unt- total.multiply(discountRate); e Bug Explorer Metrics- ssa25-shoppingcart-McCabe Cyclomatic Complexity (avg... Violations Ou Checkstyle violation "X' is a magic number." -1 occurrences In Folder Line Message urce pingCart.java/ssa25-shoppingcart/src/modelExplanation / Answer
The class constatnt can be defined as follows:
public final float twenty = 20.0;
Now in the given code , 20.0 can be replaced with twenty
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.