Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            string choice = null;

            string   AccName = "";
            double   Balance = 0;
            Checking Check1  = new Checking();

            do
            {
                Console.Write("[O]pen Account [I]nquire [D]eposit [W]ithdraw [Q]uit: ");
                choice = Console.ReadLine();
                choice = choice.ToUpper();



                switch (choice)
                {
                case "O":

                    Console.Write("Account holder: ");
                    AccName = Console.ReadLine();
                    Console.Write("Initial Deposite: ");
                    Balance = double.Parse(Console.ReadLine());
                    Console.Write("Account for {0} with Balance {1}\n", AccName, Balance);
                    Check1.setName(AccName);
                    Check1.setBalance(Balance);
                    continue;

                case "I":

                    Console.Write("Account: {0}\nBalance: {1}\n", Check1.getName(), Check1.getBalance());
                    continue;

                case "D":

                    Console.Write("Account: {0}\n Deposite: ", Check1.getName());
                    double Deposit = double.Parse(Console.ReadLine());
                    Balance = Balance + Deposit;
                    Console.Write("Balance: {0}\n", Balance);
                    Check1.setBalance(Balance);
                    continue;

                case "W":

                    Console.Write("Account: {0}\n Withdraw: ", AccName);
                    double Withdraw = double.Parse(Console.ReadLine());
                    Balance = Balance - Withdraw;
                    Console.Write("Balance: {0}\n", Balance);
                    Check1.setBalance(Balance);
                    continue;


                default: break;
                }
            } while (choice != "Q");
        }
Ejemplo n.º 2
0
        public static void Main(string[] args)
        {
            const decimal OPENING_BALANCE  = 55m;
            const decimal MONTHLY_INTEREST = 0.0033m;

            // Create and use Savings object
            Savings savings = new Savings(OPENING_BALANCE);

            savings.AddMonthlyInterest(MONTHLY_INTEREST);
            savings.ShowBalance();

            // Create and use Checking object
            Checking checking = new Checking(OPENING_BALANCE);

            checking.DeductServiceCharge();
            checking.ShowBalance();

            // Create and use JointSavings object
            JointSavings jointSavings = new JointSavings("George", "Jane", OPENING_BALANCE);

            jointSavings.AddMonthlyInterest(MONTHLY_INTEREST);
            jointSavings.ShowBalance();
            Console.ReadLine();
        }
Ejemplo n.º 3
0
        public static void Main()
        {
            string   name    = null;
            double   balance = 0.0;
            double   money   = 0.0;
            string   choice  = null;
            Checking chk     = new Checking();

            do
            {
                Console.Write("[O]pen Account     [I]nquire     [D]eposit     [W]ithdraw     [Q]uit: ");
                choice = Console.ReadLine();
                choice = choice.ToUpper();

                switch (choice)
                {
                case "O":     // open an account
                    Console.Write("Account in name of: ");
                    name = Console.ReadLine();

                    Console.Write("Initial Deposit: ");
                    balance = double.Parse(Console.ReadLine());

                    chk.Open(name, balance);

                    Console.WriteLine("The account has been opened for {0}, Balance: ${1}\n", name, balance);
                    break;

                case "I":     // inquire
                    Console.WriteLine("{0}'s Account", chk.GetName());
                    Console.WriteLine("Balance: ${0}", chk.GetBalance());
                    break;

                case "D":     // deposit
                    Console.WriteLine("{0}'s Account", chk.GetName());
                    Console.Write("Deposit: ");
                    money = double.Parse(Console.ReadLine());
                    chk.Deposit(money);
                    Console.WriteLine("Balance: ${0}", chk.GetBalance());
                    break;

                case "W":     // withdraw
                    Console.WriteLine("{0}'s Account", chk.GetName());
                    Console.Write("Withdraw: ");
                    money = double.Parse(Console.ReadLine());
                    if (money > chk.GetBalance())
                    {
                        Console.WriteLine("Error: ${0} exceeds balance: ${1}", money, balance);
                    }
                    else
                    {
                        chk.Withdraw(money);
                        Console.WriteLine("Balance: ${0}", chk.GetBalance());
                    }
                    break;

                case "Q":
                    Console.Write("Thank you, bye!");
                    Console.ReadLine();
                    return;

                default: break;
                }
            } while (choice != "Q");
        }