SHARE
TWEET

Untitled

a guest May 16th, 2019 92 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. public class Coins {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         double rest = Double.parseDouble(scanner.nextLine());
  8.         double exchange = rest*100;
  9.         int counter = 0;
  10.  
  11.         while (exchange>0){
  12.             if (exchange-200>=0){
  13.                 exchange = exchange-200;
  14.                 counter++;
  15.             }else if (exchange-100>=0){
  16.                 exchange = exchange-100;
  17.                 counter++;
  18.             }else if (exchange-50>=0){
  19.                 exchange=exchange-50;
  20.                 counter++;
  21.             }else if (exchange-20>=0){
  22.                 exchange = exchange-20;
  23.                 counter++;
  24.             }else if (exchange-10>=0){
  25.                 exchange=exchange-10;
  26.                 counter++;
  27.             }else if (exchange-5>=0){
  28.                 exchange=exchange-5;
  29.                 counter++;
  30.             }else if (exchange-2>=0){
  31.                 exchange=exchange-2;
  32.                 counter++;
  33.             }else if (exchange-1>=0){
  34.                 exchange=exchange-1;
  35.                 counter++;
  36.             }
  37.         }
  38.         System.out.println(counter);
  39.  
  40.     }
  41. }
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