Hey all, am currently working on a small project, where the user enters an amount in cents and the program will input the least amount of coins needed (2 dollars, 1 dollars, 50 cents, 20 cents, 10 cents, 5 cents and 1 cents).

Example Output...

Please Enter amount in cents: 477

Least number of coins needed is as follows

2 coins – 2

1 coins – 0

50 cents coins – 1

20 cents coins – 1

10 cents coins – 0

5 cents coin – 1

1 cent coins – 2

Total coins needed 7.

So far i have done:

import java.util.* public class CoinCounter { public static void main (String [] args){ Scanner sc = new Scanner(System.in); int amount; int oneDollar int twoDollar; int fiftyCents; int twentyCents; int tenCents; int fiveCents; int oneCents; int totalCoins = 0; System.out.println("Enter amount in cents: ") amount=sc.nextInt(); System.out.println((amount / 200) + " – $2 coins"); amount = amount % 200; System.out.println((amount / 100) + " – $1 coins"); amount = amount % 100; System.out.println((amount / 50) + " – $0.50 coins"); amount = amount % 50; System.out.println((amount / 20) + " – $0.20 coins"); amount = amount % 20; System.out.println((amount / 10) + " – $0.10 coins"); amount = amount % 10; System.out.println((amount / 5) + " – $0.05 coins"); amount = amount % 5; System.out.println(amount + " – $0.01 coins"); } }

Im not sure if that is correct, but im now stuck on what i should do next?