Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Coins_2
- {
- class Program
- {
- static void Main(string[] args)
- {
- decimal price = decimal.Parse(Console.ReadLine());
- decimal paid = decimal.Parse(Console.ReadLine());
- decimal amountChange = paid - price;
- int onelev = 0;
- int fifty = 0;
- int twenty = 0;
- int ten = 0;
- int five = 0;
- int two = 0;
- int one = 0;
- while (amountChange != 0)
- {
- if (amountChange >= 1m)
- {
- amountChange -= 1m;
- onelev++;
- }
- else if (amountChange >= 0.5m)
- {
- amountChange -= 0.5m;
- fifty++;
- }
- else if (amountChange >= 0.2m)
- {
- amountChange -= 0.2m;
- twenty++;
- }
- else if (amountChange >= 0.1m)
- {
- amountChange -= 0.1m;
- ten++;
- }
- else if (amountChange >= 0.05m)
- {
- amountChange -= 0.05m;
- five++;
- }
- else if (amountChange >= 0.02m)
- {
- amountChange -= 0.02m;
- two++;
- }
- else if (amountChange >= 0.01m)
- {
- amountChange -= 0.01m;
- one++;
- }
- }
- if (onelev > 0) Console.WriteLine($"{onelev} x 1 lev");
- if (fifty > 0) Console.WriteLine($"{fifty} x 50 stotinki");
- if (twenty > 0) Console.WriteLine($"{twenty} x 20 stotinki");
- if (ten > 0) Console.WriteLine($"{ten} x 10 stotinki");
- if (five > 0) Console.WriteLine($"{five} x 5 stotinki");
- if (two > 0) Console.WriteLine($"{two} x 2 stotinki");
- if (one > 0) Console.WriteLine($"{one} x 1 stotinka");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement