Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package S5_WhileLoops;
- import java.util.Scanner;
- public class Coins {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double money = Double.parseDouble(scanner.nextLine());
- double moneyInSt = money * 100;
- int coinsCount = 0;
- while (moneyInSt > 0) {
- if(moneyInSt >= 200) {
- moneyInSt -= 200;
- } else if(moneyInSt >= 100) {
- moneyInSt -= 100;
- } else if(moneyInSt >= 50) {
- moneyInSt -= 50;
- } else if(moneyInSt >= 20) {
- moneyInSt -= 20;
- } else if(moneyInSt >= 10) {
- moneyInSt -= 10;
- } else if(moneyInSt >= 5) {
- moneyInSt -= 5;
- } else if(moneyInSt >= 2) {
- moneyInSt -= 2;
- } else if(moneyInSt >= 1) {
- moneyInSt -= 1;
- } else {
- break;
- }
- coinsCount++;
- }
- System.out.println(coinsCount);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement