Exemplo n.º 1
0
        private void Calculate_Click(object sender, RoutedEventArgs e)
        {
            var IsValidatePrice       = Double.TryParse(InputPrice.Text, out var price);
            var IsValidateCustomerPay = Double.TryParse(InputCustomerPay.Text, out var customerPay);
            var change = sut.ComputeChange(price, customerPay);
            var result = sut.GetChangeBankNotesAndCoins(change);

            result.BankNotesAndCoins.TryGetValue(BankNotesAndCoinsInSatang.Thousand, out var Thousand);
            result.BankNotesAndCoins.TryGetValue(BankNotesAndCoinsInSatang.FiveHundreds, out var FiveHundred);
            result.BankNotesAndCoins.TryGetValue(BankNotesAndCoinsInSatang.Hundred, out var Hundred);
            result.BankNotesAndCoins.TryGetValue(BankNotesAndCoinsInSatang.Fifty, out var Fifty);
            result.BankNotesAndCoins.TryGetValue(BankNotesAndCoinsInSatang.Twenty, out var Twenty);
            result.BankNotesAndCoins.TryGetValue(BankNotesAndCoinsInSatang.Ten, out var Ten);
            result.BankNotesAndCoins.TryGetValue(BankNotesAndCoinsInSatang.Five, out var Five);
            result.BankNotesAndCoins.TryGetValue(BankNotesAndCoinsInSatang.One, out var One);
            result.BankNotesAndCoins.TryGetValue(BankNotesAndCoinsInSatang.TwentyFifth, out var TwentyFiveStang);
            result.BankNotesAndCoins.TryGetValue(BankNotesAndCoinsInSatang.Fiftieth, out var FiftyStang);
            if (IsValidatePrice && IsValidateCustomerPay && price >= 0 && customerPay >= 0 && customerPay >= price)
            {
                MoneyChangeResult.Text    = result.RoundedChange.ToString();
                countThousand.Text        = Thousand.ToString();
                countFiveHundred.Text     = FiveHundred.ToString();
                countHundred.Text         = Hundred.ToString();
                countFifty.Text           = Fifty.ToString();
                countTwenty.Text          = Twenty.ToString();
                countTen.Text             = Ten.ToString();
                countFive.Text            = Five.ToString();
                countOne.Text             = One.ToString();
                countTwentyFiveStang.Text = TwentyFiveStang.ToString();
                countFiftyStang.Text      = FiftyStang.ToString();
                StatusChange.Text         = "จ่ายเงินเรียบร้อย";
            }
            else
            {
                MoneyChangeResult.Text    = "";
                countThousand.Text        = "";
                countFiveHundred.Text     = "";
                countHundred.Text         = "";
                countFifty.Text           = "";
                countTwenty.Text          = "";
                countTen.Text             = "";
                countFive.Text            = "";
                countOne.Text             = "";
                countTwentyFiveStang.Text = "";
                countFiftyStang.Text      = "";
                StatusChange.Text         = "";
                StatusChange.Text         = "กรอกจำนวนเงินไม่ถูกต้อง";
            }
        }
Exemplo n.º 2
0
        static void Uri1018(string[] args)
        {
            int N;
            int Change;
            int Hundred, Fifty, Twenty, Ten, Five, Two, One;

            N = int.Parse(Console.ReadLine());

            Change = N;

            Hundred = Change / 100;
            Change  = Change - (Hundred * 100);

            Fifty  = Change / 50;
            Change = Change - (Fifty * 50);

            Twenty = Change / 20;
            Change = Change - (Twenty * 20);

            Ten    = Change / 10;
            Change = Change - (Ten * 10);

            Five   = Change / 5;
            Change = Change - (Five * 5);

            Two    = Change / 2;
            Change = Change - (Two * 2);

            One    = Change / 1;
            Change = Change - (One * 1);

            Console.WriteLine(N.ToString());
            Console.WriteLine(Hundred.ToString() + " nota (s) de R$ 100,00");
            Console.WriteLine(Fifty.ToString() + " nota (s) de R$ 50,00");
            Console.WriteLine(Twenty.ToString() + " nota (s) de R$ 20,00");
            Console.WriteLine(Ten.ToString() + " nota (s) de R$ 10,00");
            Console.WriteLine(Five.ToString() + " nota (s) de R$ 5,00");
            Console.WriteLine(Two.ToString() + " nota (s) de R$ 2,00");
            Console.WriteLine(One.ToString() + " nota (s) de R$ 1,00");
        }