I would also make a interfacean interface
of these methods as well something like this:
interface investmentCompound
{
double getQuarters(double numOfQuarters);
double getDimes(double numOfDimes);
double getNickles(double numOfNickles);
double performCalculations();
double formatPrice(double priceToFormat);
...
}
The above will give your class a much better design and help you better code as well. Always program in such a way that when anyone reads your code, the method and variable names are self-explainatoryexplanatory on what your class is doing.
Give your
main()
function the minimal capability to just call methods and variables instead of declaring everything there.In realworldthe real world, you will always have aan API i.e. getters and setters and methods like how I mentioned in the interface above so this will give you. This is better practice, so when someone wants to call your code, they should be able to use the methods.
Since you are going to use
numOfNickles,
,numOfQuarters,
,numOfDimes
variable names several times, itsit's best to declare that at class level, so declare them as class variables instead of inmain()
.