Ejemplo n.º 1
0
        //Payment methods
        public static decimal PayCash(decimal grandTotal)
        {
            decimal amount = 0m, change = 0m;
            bool    doAgain = false;

            //Get amount they are paying
            do
            {
                Console.WriteLine("Please enter the amount of cash you would like to apply:");

                amount = Validation.ValidCash(Console.ReadLine());

                if (amount == grandTotal)
                {
                    Console.WriteLine("Paid in full");
                    change = grandTotal - amount;
                    return(change);
                }
                else if (amount > grandTotal)
                {
                    change = amount - grandTotal;
                    Console.WriteLine($"Change: {change}");
                    return(change);
                }
                else
                {
                    Console.WriteLine("That is not a valid amount.");
                    doAgain = true;
                }
            } while (doAgain == true);
            return(0m);
        }