-3
    String choice = "y";
    while(choice.equalsIgnoreCase("y")){
        if (cents <= 99 && cents > 0){
        quarters = cents / quarters;
        System.out.println("Quarters: " + quarters);

        dimes = cents / dimes;
        System.out.println("Dimes: " + dimes);

        nickels = cents / nickels;
        System.out.println("Nickels: " + nickels);

        pennies = cents / pennies;
        System.out.println("Pennies: " + pennies);

Do i need to implement a modulus operator after each step?

  • Welcome to Stack Overflow! It looks like you may be asking for homework help. While we have no issues with that per se, please observe these [dos and don'ts](http://meta.stackoverflow.com/questions/334822/how-do-i-ask-and-answer-homework-questions/338845#338845), and edit your question accordingly. (Even if this isn't homework, please consider the advice anyway.) – Joe C Apr 02 '17 at 20:43
  • suppose you are confused with int division . this post might be helpful.(http://stackoverflow.com/questions/4685450/why-is-the-result-of-1-3-0) – Rajith Pemabandu Apr 02 '17 at 20:51
  • thank you i appreciate the help – user7805798 Apr 02 '17 at 20:55

1 Answers1

0

Ah you have a can't see the wood for the trees problem.

Old school trick this called a dry run

Cents Quarters Dimes Nickels Pennies Remaining Cents
41    1                              16
16             1                     6
6                       1            1
1                               1    0

You are starting from 41 each calculation.

Tony Hopkinson
  • 20,172
  • 3
  • 31
  • 39