Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class FinalOne {
- public static void main(String[] args) {
- {
- System.out.println("Amount Coins");
- while (true) {
- int amount = BIO.getInt();
- int fullamount = amount;
- int twoHundredPCoin = 0;
- int oneHundredPCoin = 0;
- int fiftyPCoin = 0;
- int twentyPCoin = 0;
- int tenPCoin = 0;
- int fivePCoin = 0;
- int twoPCoin = 0;
- int onePCoin = 0;
- int coincounter = 0;
- String twohun_out = "";
- String onehuu_out = "";
- String fifty_out = "";
- String twinty_out = "";
- String ten_out = "";
- String five_out = "";
- String two_out = "";
- String one_out = "";
- if (amount > 500) {
- break;
- }
- if (amount < 1)
- {
- break;
- }
- else
- {
- while (amount >= 200) {
- twoHundredPCoin = twoHundredPCoin + 1;
- amount = amount - 200;
- coincounter++;
- }
- while (amount >= 100) {
- oneHundredPCoin = oneHundredPCoin + 1;
- amount = amount - 100;
- coincounter++;
- }
- while (amount >= 50) {
- fiftyPCoin = fiftyPCoin + 1;
- amount = amount - 50;
- coincounter++;
- }
- while (amount >= 20) {
- twentyPCoin = twentyPCoin + 1;
- amount = amount - 20;
- coincounter++;
- }
- while (amount >= 10) {
- tenPCoin = tenPCoin + 1;
- amount = amount - 10;
- coincounter++;
- }
- while (amount >= 5) {
- fivePCoin = fivePCoin + 1;
- amount = amount - 5;
- coincounter++;
- }
- while (amount >= 2) {
- twoPCoin = twoPCoin + 1;
- amount = amount - 2;
- coincounter++;
- }
- while (amount >= 1) {
- onePCoin = onePCoin + 1;
- amount = amount - 1;
- coincounter++;
- }
- if (twoHundredPCoin >= 1) {
- if (twoHundredPCoin == 1) {
- twohun_out = "200p";
- } else
- twohun_out = twoHundredPCoin + "*200p";
- }
- if (oneHundredPCoin >= 1) {
- if (oneHundredPCoin == 1) {
- onehuu_out = "100p";
- } else
- onehuu_out = oneHundredPCoin + "*100p";
- }
- if (fiftyPCoin >= 1) {
- if (fiftyPCoin == 1) {
- fifty_out = " 50p";
- } else
- fifty_out = fiftyPCoin + "*50p";
- }
- if (twentyPCoin >= 1) {
- if (twentyPCoin == 1) {
- twinty_out = " 20p";
- } else
- twinty_out = twentyPCoin + "*20p";
- }
- if (tenPCoin >= 1) {
- if (tenPCoin == 1) {
- ten_out = " 10p";
- } else
- ten_out = tenPCoin + "*10p";
- }
- if (fivePCoin >= 1) {
- if (fivePCoin == 1) {
- five_out = " 5p";
- } else
- five_out = fivePCoin + "*5p";
- }
- if (twoPCoin >= 1) {
- if (twoPCoin == 1) {
- two_out = " 2p";
- } else
- two_out = twoPCoin + "*2p";
- }
- if (onePCoin >= 1) {
- if (onePCoin == 1) {
- one_out = " 1p";
- } else
- one_out = onePCoin + "*1p";
- }
- System.out.print((fullamount) + "p" + " " +
- coincounter + " coins "
- + twohun_out + " "
- + onehuu_out + " "
- + fifty_out + " "
- + twinty_out + " "
- + ten_out + " "
- + five_out + " "
- + two_out + " "
- + one_out + " ");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement