SHARE
TWEET

monets

a guest Feb 16th, 2020 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. public class Monets {
  4.     public static void main(String[] args) {
  5.         Scanner scan = new Scanner(System.in);
  6.         Double monetsIn = Double.parseDouble(scan.nextLine()) *100;
  7.         int cntMonets = 0;
  8.         while (monetsIn > 0) {
  9.  
  10.             if (monetsIn >= 200){
  11.                 monetsIn = monetsIn -200;
  12.                 cntMonets++;
  13.             } else if (monetsIn >= 100) {
  14.                 monetsIn = monetsIn -100;
  15.                 cntMonets++;
  16.             }  else if (monetsIn >= 50) {
  17.                 monetsIn = monetsIn -50;
  18.                 cntMonets++;
  19.             } else if (monetsIn >= 20) {
  20.                 monetsIn = monetsIn -20;
  21.                 cntMonets++;
  22.             }  else if (monetsIn >= 10) {
  23.                 monetsIn = monetsIn -10;
  24.                 cntMonets++;
  25.             } else if (monetsIn >= 5) {
  26.                 monetsIn = monetsIn -5;
  27.                 cntMonets++;
  28.             } else if (monetsIn >= 2) {
  29.                 monetsIn = monetsIn -2;
  30.                 cntMonets++;
  31.             } else if (monetsIn >= 1) {
  32.                 monetsIn = monetsIn -1;
  33.                 cntMonets++;
  34.             }
  35.         }
  36.         System.out.println(cntMonets);
  37.     }
  38. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top