This content has been marked as final. Show 2 replies
Looks like a simple caculation is needed. What exactly is your problem with that?
Your Coins class should not have a field total (and consequently, there should not be a constructor parameter for total nor a getter method for total). Instead of your current approach, there should be a method public String calcTotalDollars() that calculates the total value of - well - the coins in the Coins instance. Similarly, there should be methods calcTotalQuarters, calcTotalDimes, etc. that express the total dollar value as quarters, dimes, etc.
As a first step, return "exact" value. Only when that works as it should, return values rounded to two fractional digits.