kalitarix

Coins

Aug 17th, 2018
1,210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.67 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Coins
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             double change = double.Parse(Console.ReadLine());
  10.  
  11.             double stotinki = change * 100;
  12.  
  13.             int countOfCoins = 0;
  14.  
  15.             while (stotinki > 0)
  16.             {
  17.                 if (stotinki >= 200)
  18.                 {
  19.                     countOfCoins++;
  20.                     stotinki -= 200;
  21.                 }
  22.                 else if (stotinki >= 100)
  23.                 {
  24.                     countOfCoins++;
  25.                     stotinki -= 100;
  26.                 }
  27.                 else if (stotinki >= 50)
  28.                 {
  29.                     countOfCoins++;
  30.                     stotinki -= 50;
  31.                 }
  32.                 else if (stotinki >= 20)
  33.                 {
  34.                     countOfCoins++;
  35.                     stotinki -= 20;
  36.                 }
  37.                 else if (stotinki >= 10)
  38.                 {
  39.                     countOfCoins++;
  40.                     stotinki -= 10;
  41.                 }
  42.                 else if (stotinki >= 5)
  43.                 {
  44.                     countOfCoins++;
  45.                     stotinki -= 5;
  46.                 }
  47.                 else if (stotinki >= 2)
  48.                 {
  49.                     countOfCoins++;
  50.                     stotinki -= 2;
  51.                 }
  52.                 else if (stotinki >= 1)
  53.                 {
  54.                     countOfCoins++;
  55.                     stotinki -= 1;
  56.                 }
  57.                 else
  58.                 {
  59.                     break;
  60.                 }
  61.             }
  62.  
  63.             Console.WriteLine(countOfCoins);
  64.         }
  65.     }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment