Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- public class MoneyCombination
- {
- public static void main (String args[]) throws IOException
- {
- DataInputStream stdin = new DataInputStream(System.in);
- System.out.print("Enter amount of money : ");
- int money = Integer.parseInt(stdin.readLine());
- int twenty = money / 20;
- int ten = money/ 10;
- int five = money /5;
- for (int i = 0; i <= twenty; i++)
- {
- for (int j = 0; j <= ten; i++)
- {
- for (int k = 0; k <= five; i++)
- {
- if (i*twenty + j * ten + i * five == money)
- {
- System.out.print("Number of twenties : " + i);
- System.out.print("\nNumber of tens : " + j);
- System.out.print("\nNumber of fives : " + k);
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement