Skip to main content
deleted 25 characters in body
Source Link
Jamal
  • 34.9k
  • 13
  • 133
  • 237

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 in main().

I would also make a 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 a way that when anyone reads your code, the method and variable names are self-explainatory 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 realworld, you will always have a API i.e. getters and setters and methods like how I mentioned in the interface above so this will give you 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, its best to declare that at class level so declare them as class variables instead of main()

I would also make an interface of these methods:

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-explanatory 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 the real world, you will always have an API i.e. getters and setters and methods like how I mentioned in the interface above. 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, it's best to declare that at class level, so declare them as class variables instead of in main().

Source Link
fscore
  • 634
  • 1
  • 7
  • 15

I would also make a 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 a way that when anyone reads your code, the method and variable names are self-explainatory 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 realworld, you will always have a API i.e. getters and setters and methods like how I mentioned in the interface above so this will give you 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, its best to declare that at class level so declare them as class variables instead of main()