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 ConsoleApplication11
- {
- class Program
- {
- static void Main(string[] args)
- {
- double[] coins = { 10, 5, 2, 1, 0.5, 0.1 };
- int[] numOfCouns = { 0, 0, 0, 0, 0, 0 };
- double price, pay, change;
- Console.Write("Enter the price of the item: ");
- price = double.Parse(Console.ReadLine());
- Console.Write("Enter your payment: ");
- pay = double.Parse(Console.ReadLine());
- change = pay - price;
- Console.WriteLine("You need to pay: ");
- for (int i = 0; i < coins.Length; i++)
- {
- while (coins[i] <= change)
- {
- numOfCouns[i]++;
- change -= coins[i];
- }
- Console.WriteLine("{0} coins of {1}", numOfCouns[i], coins[i]);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement