Пример #1
0
        private static void BankMenu(Savings savings, Chequings chequings, GlobalSavingsAccount globalSavingsAccount)
        {
            Console.WriteLine("Select the Type of Account");
            Console.WriteLine("A: Savings \n" +
                              "B: Checking \n" +
                              "C: GlobalSavings \n" +
                              "Q: Exit \n");
            option = Console.ReadLine();
            option = option.ToUpper();

            switch (option.ToUpper())
            {
            case "A":
                SavingsMenu();
                break;

            case "B":
                CheckingMenu();
                break;

            case "C":
                GlobalSavingsMenu();

                break;

            case "Q":

                break;

            default:
                Console.WriteLine("NOT A VALID OPTION");
                BankMenu(savings, chequings, globalSavingsAccount);
                break;
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            var cd1 = new CertifacteofDeposit(Amount: 1000, Months: 12);

            cd1.WithdrawDate = DateTime.Now.AddDays(2);
            var funds = cd1.Withdraw();

            var sav1 = new Savings();

            sav1.Deposit(1000);
            sav1.PayInterest(3);


            var acct1 = new account();

            acct1.Deposit(500);
            acct1.Withdraw(200);
            acct1.Withdraw(600);
            acct1.Deposit(-400);
            Console.WriteLine($"Balance is {acct1.Balance}");


            var acct2 = new account();

            acct1.Transfer(1000, acct2);
            Console.WriteLine($"Balance is {acct1.Balance}");
            Console.WriteLine($"Balance is {acct2.Balance}");
        }
Пример #3
0
        static void Main(string[] args)
        {
            Checking Checking = new Checking("45069", "This is my checking account")
            {
                Owner = "Fields, Marcus",
            };

            Checking.Deposit(10000);
            Checking.Withdrawl(500);
            Checking.WriteCheck("Porsche of Kings Auto Mall", 300);

            Savings Savings = new Savings("45070", "This is my savings account")
            {
                Owner       = "Fields, Marcus",
                Description = "This is my savings account"
            };

            Savings.Deposit(2000);
            Savings.Withdrawl(700);

            List <Account> Accounts = new List <Account> {
                Checking, Savings
            };
            decimal TotalOfAllAccounts = 0;

            foreach (Account Account in Accounts)
            {
                TotalOfAllAccounts += Account.GetBalance();
                Account.Print();
            }
        }
Пример #4
0
        static void Main(string[] args)
        {
            const decimal OPENING_BALANCE  = 55m;
            const decimal MONTHLY_INTEREST = 0.0033m;

            //add monthly interest to savings account and display balance
            Savings savings = new Savings(OPENING_BALANCE);

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

            //deduct the monthly check fee from the account balance and display balance
            Checking checking = new Checking(OPENING_BALANCE);

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

            //show the 2 owners of the joint account, plus add interest to the balance and display the balance
            JointSavings jointSavings = new JointSavings("Bob", "Martha", OPENING_BALANCE);

            jointSavings.ShowOwners();
            jointSavings.AddMonthlyInterest(MONTHLY_INTEREST);
            jointSavings.ShowBalance();
            Console.ReadKey();
        }
Пример #5
0
        //check push
        void Run()
        {
            Account checking = new Account("Checking");

            checking.Deposit(300.00);

            Savings savings = new Savings("Savings with Interest", 0.1);             // creates a new instance of Savings with name and interest rate

            savings.Deposit(18000.00);
            savings.PayMonthlyInterest();

            //creates an array containing all properties of savings and checking account properties
            // then prints properties of both accounts
            List <Account> myAccounts = new List <Account>();

            myAccounts.Add(savings);
            myAccounts.Add(checking);
            foreach (var account in myAccounts)
            {
                Console.WriteLine(account.ToPrint());
            }
            // some account class methods
            checking.Withdraw(20.00);
            savings.Transfer(100.00, checking);
            foreach (var account in myAccounts)
            {
                Console.WriteLine(account.ToPrint());
            }
        }
Пример #6
0
        static void Main(string[] args)
        {
            var sav1 = new Savings(0.12, "My Savings");

            sav1.Deposit(1000);
            sav1.Print();
            sav1.PayInterest(1);
            sav1.Print();

            var sav2 = new Savings2(0.12, "My Composite Savings");

            sav2.Deposit(1000);
            sav2.Print();
            sav2.PayInterest(1);
            sav2.Print();

            Savings2.Transfer(100, sav1, sav2);

            var acct1 = new Account();
            var acct2 = new Account("My Checking");

            Account.Deposit(500, acct1);
            acct1.Print();
            acct2.Print();
            acct2.Deposit(1000);
            acct2.Withdraw(2000);
            acct2.Print();

            try {
                acct2.Withdraw(5000);
                acct2.Print();
                acct2.Deposit(-200);
                acct2.Print();
                acct2.Withdraw(-200);
                acct2.Print();
            } catch (InsufficientFundsException ex) {
                Console.WriteLine($"Insufficient Funds: Acct: {ex.AccountId}, Amt: {ex.AmountToWithdraw}, Bal: {ex.Balance}");
            } catch (DivideByZeroException ex) {
                Console.WriteLine("Attempted to divide by zero");
            } catch (Exception ex) {
                Console.WriteLine(ex.Message);
            }

            var success = Account.Transfer(200, acct2, acct1);

            if (success)
            {
                Console.WriteLine("The transfer worked!");
            }
            else
            {
                Console.WriteLine("The transfer failed!");
            }
            acct2.Print();
            acct1.Print();
        }
Пример #7
0
        static void Main(string[] args)
        {
            var act100 = new Account();

            act100.Deposit(-100);
            try
            {
                act100.Withdrawal(12000);
            }
            catch (InsufficientFundsException ex) { }

            catch (DivideByZeroException ex) { throw; }

            catch (Exception ex) { }  //do this one last always since first exception that is true is thrown

            var sv1 = new Savings2();

            sv1.Deposit(2000);
            var cd10     = new CertificateOfDeposit(5000, 60);
            var accounts = new IBanking[] { sv1, cd10 };

            foreach (var acct in accounts)
            {
                Console.WriteLine($"Account balance is {acct.GetBalance()}"); //need to add composition method for CD for this to work
            }



            var sav1 = new Savings();

            sav1.Deposit(1000);
            sav1.PayInterest(3);


            var acct1 = new Account();

            acct1.Deposit(500);
            acct1.Withdrawal(200);
            acct1.Withdrawal(600);
            acct1.Deposit(-400);
            Console.WriteLine($"Balance is {acct1.Balance}");

            var acct2 = new Account();

            acct1.Transfer(1000, acct2);
            Console.WriteLine($"Balance is {acct1.Balance}");
            Console.WriteLine($"Balance is {acct2.Balance}");

            var cd1 = new CertificateOfDeposit(Amount: 1000, Months: 12);

            cd1.Deposit(1);
            cd1.Withdrawal(1);
            cd1.WithdrawlDate = DateTime.Now.AddDays(-1); //yesterday
            var funds = cd1.Withdrawal();                 //no parameters sine we will withdraw everything in acocunt
        }
Пример #8
0
        static void Main(string[] args)
        {
            var sav1 = new Savings(0.12, "My Savings");

            sav1.Deposit(1000);
            sav1.Print();
            sav1.PayInterest(1); // pay interest for one month
            sav1.Print();

            var sav2 = new Savings2(0.12, "My Composite Savings");  // Done with composite in stead of inherited class

            sav2.Deposit(1000);
            sav2.Print();
            sav2.PayInterest(1);
            sav2.Print();

            Savings2.Transfer(100, sav1, sav2);


            var acct1 = new Account();
            var acct2 = new Account("My Checking");

            try {
                Account.Deposit(500, acct1);
                acct1.Print();
                acct2.Print();
                acct2.Deposit(1000);
                acct2.Print();
                acct2.Withdraw(50);
                acct2.Print();
                acct2.Deposit(-200);
                acct2.Print();
                acct2.Withdraw(-200);
                acct2.Print();
            } catch (DivideByZeroException ex) {
                Console.WriteLine("Attempted to divide by zero");
            } catch (Exception ex) {
                Console.WriteLine(ex.Message);
            }

            var success = Account.Transfer(200, acct2, acct1);

            if (success)
            {
                Console.WriteLine("The transfer worked!");
            }
            else
            {
                Console.WriteLine("The transfer failed!");
            }
            acct2.Print();
            acct1.Print();
        }
Пример #9
0
        static void Main(string[] args)
        {
            var sav1 = new Savings(0.12, "My Savings");

            sav1.Deposit(1000);
            sav1.Print();
            var interest = sav1.CalculateInterest(1);

            sav1.PayInterest(1);
            sav1.Print();

            var sav2 = new Savings2(0.12, "My Composite Savings");

            sav2.Deposit(1000);
            sav2.Print();
            sav2.PayInterest(1);

            var acct1 = new Account();
            var acct2 = new Account("My Checking");

            try {
                acct2.Print();
                acct2.Deposit(1000);
                acct2.Print();
                acct2.Withdraw(50);
                acct2.Print();
                acct2.Deposit(-200);
                acct2.Print();
                acct2.Withdraw(-200);
                acct2.Print();
            } catch (DivideByZeroException) {
                Console.WriteLine("Attempted to divide by zero");
            } catch (Exception ex) {
                Console.WriteLine(ex.Message);
            }
            var success = Account.Transfer(200, acct2, acct1);

            if (success)
            {
                Console.WriteLine("The transfer worked!");
            }
            else
            {
                Console.WriteLine("The transfer failed!");
            }
            acct2.Print();
            acct1.Print();
        }
Пример #10
0
        public ArrayList GetAccounts()
        {
            ArrayList accounts = new ArrayList();

            using (inFile = new StreamReader(filename))
            {
                int     customerID;
                int     accountID;
                string  firstName;
                string  lastName;
                decimal balance;
                int     accountType;
                string  line = string.Empty;

                while ((line = inFile.ReadLine()) != null)
                {
                    string [] data = line.Split(DELIMETER.ToCharArray()[0]);

                    customerID  = Convert.ToInt32(data[0]);
                    accountID   = Convert.ToInt32(data[1]);
                    firstName   = Convert.ToString(data[2]);
                    lastName    = Convert.ToString(data[3]);
                    balance     = Convert.ToDecimal(data[4]);
                    accountType = Convert.ToInt32(data[5]);

                    Customer customer = new Customer(customerID, firstName, lastName);
                    Account  account;

                    Account.ACCOUNTTYPE type = (Account.ACCOUNTTYPE)accountType;
                    if (type == Account.ACCOUNTTYPE.CHECKING)
                    {
                        account = new Checking(customer, accountID, Convert.ToDecimal(balance));
                    }
                    else
                    {
                        account = new Savings(customer, accountID, Convert.ToDecimal(balance));
                    }

                    accounts.Add(account);
                }
                inFile.Close();
            }
            return(accounts);
        }
Пример #11
0
        // Run method pushed up to GitHub

        void TestAccount()
        {
            Account checking = new Account();

            checking.SetName("Checking 1");
            checking.Withdraw(100.00);
            checking.Deposit(50.00);
            checking.Deposit(-100.00);
            Console.WriteLine($"Account Nbr:{checking.getNumber()}, Name: {checking.GetName()}, balance is {checking.CheckBalance()}");
            Savings savings = new Savings("My Savings Account");

            savings.IntRate = 0.10;
            savings.Deposit(70.00);
            Console.WriteLine($"Account Nbr:{savings.getNumber()}, Name: {savings.GetName()}, balance is {savings.CheckBalance()}");

            savings.Transfer(30.00, checking);

            Console.WriteLine($"Account Nbr:{checking.getNumber()}, Name: {checking.GetName()}, balance is {checking.CheckBalance()}");
            Console.WriteLine($"Account Nbr:{savings.getNumber()}, Name: {savings.GetName()}, balance is {savings.CheckBalance()}");

            checking.Transfer(-10.00, savings);

            Console.WriteLine($"Account Nbr:{checking.getNumber()}, Name: {checking.GetName()}, balance is {checking.CheckBalance()}");
            Console.WriteLine($"Account Nbr:{savings.getNumber()}, Name: {savings.GetName()}, balance is {savings.CheckBalance()}");

            savings.Transfer(100.00, checking);

            Console.WriteLine($"Account Nbr:{checking.getNumber()}, Name: {checking.GetName()}, balance is {checking.CheckBalance()}");
            Console.WriteLine($"Account Nbr:{savings.getNumber()}, Name: {savings.GetName()}, balance is {savings.CheckBalance()}");

            savings.PayMonthlyInterest();

            Console.WriteLine($"Savings Nbr:{savings.getNumber()}, Name: {savings.GetName()}, balance is {savings.CheckBalance()}");

            Savings sav1 = new Savings("Greg's Savings with Interest", 0.05);
        }
Пример #12
0
        static int Main(string[] args)
        {
            Account acct1 = new Account();

            acct1.Id          = 1;
            acct1.Description = "Primary Account";
            acct1.Balance     = 0.0;
            acct1.Owner       = new Customer(100, "W Michael Robinson");
            Console.WriteLine(acct1.ToPrint());

            acct1.Deposit(-5.00);
            Console.WriteLine("The balance is " + acct1.GetBalance() + ".");

            acct1.Deposit(5.00);
            Console.WriteLine("The balance is " + acct1.GetBalance() + ".");

            acct1.Withdraw(5000.00);
            Console.WriteLine("The balance is " + acct1.GetBalance() + ".");

            Savings sav2 = new Savings();

            sav2.Id          = 2;
            sav2.Description = "Primary Savings Account";
            sav2.Balance     = 0.0;
            sav2.Owner       = new Customer(101, "Lisa Simpson");
            sav2.IntRate     = 0.12;

            sav2.Deposit(1000.00);
            Console.WriteLine(sav2.ToPrint());

            Checking chk1 = new Checking();

            chk1.Id          = 3;
            chk1.Description = "Primary Checking Account";
            chk1.Balance     = 0.0;
            chk1.Owner       = new Customer(102, "Homer Simpson");

            chk1.Deposit(2000.00);
            Console.WriteLine(chk1.ToPrint());

            Checking chka = new Checking();

            chka.Id          = 3;
            chka.Description = "Primary Checking Account";
            chka.Balance     = 0.0;
            chka.Owner       = new Customer(102, "Homer Simpson");

            chka.Deposit(2000.00);

            Checking chkb = new Checking();

            chkb.Id          = 3;
            chkb.Description = "Secondary Checking Account";
            chkb.Balance     = 0.0;
            chkb.Owner       = new Customer(102, "Homer Simpson");

            chkb.Deposit(2000.00);

            Savings sava = new Savings();

            sava.Id          = 2;
            sava.Description = "Primary Savings Account";
            sava.Balance     = 0.0;
            sava.Owner       = new Customer(102, "Homer Simpson");
            sava.IntRate     = 0.12;

            sava.Deposit(1000.00);

            Investment inv1 = new Investment();

            inv1.Deposit(500.00);
            Console.WriteLine(inv1.ToPrint());

            IAccountStatement[] accountsArray = { chka, chkb, sava, inv1 };

            double grandTotal = 0;

            foreach (IAccountStatement acct in accountsArray)
            {
                double acctBalance = acct.GetBalance();
                grandTotal = grandTotal + acctBalance;
                Console.WriteLine(acct.ToPrint());
            }

            Console.WriteLine("Grand Total is " + grandTotal);

            Console.ReadKey();
            return(0);
        }
Пример #13
0
        static void Main(string[] args)

        /*Banking console application with 1 base class and 3 derived classes.
         * Would like to add exception handling on the some of the option selections
         * at some point in the near future.*/
        {
            //Instantiation of the 3 derived classes
            Savings  mySavingsAccount  = new Savings();
            Checking myCheckingAccount = new Checking();
            Reserve  myReserveAccount  = new Reserve();

            //Creation of Stream writer files
            StreamWriter savingsFile  = new StreamWriter("Savings.txt");
            StreamWriter checkingFile = new StreamWriter("Checking.txt");
            StreamWriter reserveFile  = new StreamWriter("Reserve.txt");

            savingsFile.WriteLine("Client: Albert King | Savings Account Number: 101");
            checkingFile.WriteLine("Client: Albert King | Checking Account Number: 801");
            reserveFile.WriteLine("Client: Albert King | Reserve Account Number: 1201");

            while (true) //Console menu
            {
                Console.WriteLine("\nPlease enter a number from the menu for one of the following banking options: ");
                Console.WriteLine("\n1) View Customer Account Information");
                Console.WriteLine("--------");
                Console.WriteLine("\nView account balance:");
                Console.WriteLine("2) Checking");
                Console.WriteLine("3) Savings");
                Console.WriteLine("4) Reserve");
                Console.WriteLine("--------");
                Console.WriteLine("\nMake a transaction:");
                Console.WriteLine("5) Deposit Money");
                Console.WriteLine("6) Withdrawal Money");
                Console.WriteLine("7) Quit");
                Console.WriteLine("Enter an option");

                int userResult = Convert.ToInt32(Console.ReadLine());
                Console.Clear();//clears console window for easier readability

                switch (userResult)
                {
                case 1:     //Gives option to view specific hard coded account info

                    Console.WriteLine("Choose account to view info");
                    Console.WriteLine("1) Checking");
                    Console.WriteLine("2) Savings");
                    Console.WriteLine("3) Reserve");

                    int accountEntered = Convert.ToInt32(Console.ReadLine());

                    switch (accountEntered)
                    {
                    case 1:
                        myCheckingAccount.CheckingCustomer();
                        break;

                    case 2:
                        mySavingsAccount.SavingsCustomer();
                        break;

                    case 3:
                        myReserveAccount.ReserveCustomer();
                        break;

                    default:
                        break;
                    }
                    break;

                case 2:     //Options to show specific account balances
                    myCheckingAccount.ShowBalance();
                    break;


                case 3:
                    mySavingsAccount.ShowBalance();
                    break;


                case 4:
                    myReserveAccount.ShowBalance();
                    break;

                case 5:    //Options for accounts to deposit to

                    Console.WriteLine("Choose account to make deposit");
                    Console.WriteLine("1) Checking");
                    Console.WriteLine("2) Savings");
                    Console.WriteLine("3) Reserve");

                    int accountChoice = Convert.ToInt32(Console.ReadLine());

                    Console.WriteLine("Enter Deposit Amount: ");

                    decimal depositAmount = decimal.Parse(Console.ReadLine());


                    switch (accountChoice)     //shows account balances after deposit
                    {
                    case 1:
                        myCheckingAccount.Deposit(depositAmount);
                        Console.WriteLine("Checking balance: $ " + myCheckingAccount.AccountBalanceChecking);
                        checkingFile.WriteLine(depositAmount + "+ " + "Balance: $" + myCheckingAccount.AccountBalanceChecking + " " + DateTime.Now);
                        break;


                    case 2:
                        mySavingsAccount.Deposit(depositAmount);
                        Console.WriteLine("Savings balance: $ " + mySavingsAccount.AccountBalanceSavings);
                        savingsFile.WriteLine(depositAmount + "+ " + "Balance: $" + mySavingsAccount.AccountBalanceSavings + " " + DateTime.Now);

                        break;


                    case 3:
                        myReserveAccount.Deposit(depositAmount);
                        Console.WriteLine("Reserve balance: $ " + myReserveAccount.AccountBalanceReserve);
                        reserveFile.WriteLine(depositAmount + "+ " + "Balance: $" + myReserveAccount.AccountBalanceReserve + " " + DateTime.Now);
                        break;


                    default:
                        break;
                    }
                    break;

                case 6:     //Accounts to withdraw from

                    Console.WriteLine("Choose account to make withdrawl from: ");
                    Console.WriteLine("1) Checking Account");
                    Console.WriteLine("2) Savings Account");
                    Console.WriteLine("3) Reserve Account");


                    int clientChoice = Convert.ToInt32(Console.ReadLine());


                    Console.WriteLine("Enter withdrawl ammount: ");


                    decimal withdrawAmount = decimal.Parse(Console.ReadLine());


                    switch (clientChoice)     //shows account balances after withdraw
                    {
                    case 1:
                        myCheckingAccount.Withdraw(withdrawAmount);
                        Console.WriteLine("Checking balance $ " + myCheckingAccount.AccountBalanceChecking);
                        checkingFile.WriteLine(withdrawAmount + "- " + "Balance: $" + myCheckingAccount.AccountBalanceChecking + " " + DateTime.Now);
                        break;


                    case 2:
                        mySavingsAccount.Withdraw(withdrawAmount);
                        Console.WriteLine("Savings balance $ " + mySavingsAccount.AccountBalanceSavings);
                        savingsFile.WriteLine(withdrawAmount + "- " + "Balance: $" + mySavingsAccount.AccountBalanceSavings + " " + DateTime.Now);
                        break;


                    case 3:
                        myReserveAccount.Withdraw(withdrawAmount);
                        Console.WriteLine("Reserve balance $ " + myReserveAccount.AccountBalanceReserve);
                        reserveFile.WriteLine(withdrawAmount + "- " + "Balance: $" + myReserveAccount.AccountBalanceReserve + " " + DateTime.Now);
                        break;
                    }
                    break;

                case 7:

                    break;


                default:

                    break;
                } //Exit procedure
                Console.WriteLine("\nThank you for banking with us.  Press C to continue or any key to exit.");

                string c = Console.ReadLine();
                if (c.ToLower() == "c")
                {
                    Console.Clear();
                }
                else
                {
                    break;
                }
            }
            savingsFile.Close();
            checkingFile.Close();
            reserveFile.Close();
        }
Пример #14
0
  { static void Main(string[] args)
    {
        Account acct1 = new Account();

        acct1.Id          = 1;
        acct1.Description = "My first checking account";
        acct1.Balance     = 0.0;
        acct1.Owner       = new Customer(100, "Greg Doud");

        acct1.Deposit(5.00);
        Console.WriteLine(acct1.ToPrint());

        acct1.Deposit(-5.00);
        Console.WriteLine("The balance is " + acct1.GetBalance() + " should be 0");

        acct1.Withdraw(-5.00);
        Console.WriteLine("The balance is " + acct1.GetBalance() + " should be 10.00");

        acct1.Withdraw(5000.00);
        Console.WriteLine("The balance is " + acct1.GetBalance() + " should be -4995.00");

        Savings sav2 = new Savings();

        sav2.Id          = 2;
        sav2.Description = "My first savings account";
        sav2.Balance     = 0.0;
        sav2.Owner       = new Customer(101, "Lisa S.");
        sav2.IntRate     = 0.12;
        sav2.Deposit(1000.00);

        Console.WriteLine(sav2.ToPrint());

        Checkings chk3 = new Checkings();

        chk3.Id          = 3;
        chk3.Description = "My first checking account";
        chk3.Balance     = 0.0;
        chk3.Owner       = new Customer(102, "Denise B.");

        chk3.Deposit(2000.00);

        Checkings chk4 = new Checkings();

        chk4.Id          = 4;
        chk4.Description = "My first checking account";
        chk4.Balance     = 0.0;
        chk4.Owner       = new Customer(102, "Kool B.");

        chk4.Deposit(2000.00);

        Savings chk5 = new Savings();

        chk5.Id          = 5;
        chk5.Description = "My first checking account";
        chk5.Balance     = 0.0;
        chk5.Owner       = new Customer(102, "Rich B.");
        chk5.IntRate     = 0.12;

        chk5.Deposit(2000.00);

        Investment inv1 = new Investment();

        inv1.Deposit(500.00);

        IAccountStatement[] accounts = { chk4, chk5, chk3, inv1 };

        double grandTotal = 0;


        foreach (Account acct in accounts)
        {
            double accBalance = acct.GetBalance();
            grandTotal = grandTotal + acct.Balance;
            Console.WriteLine(acct.ToPrint());
        }
        Console.WriteLine("Grand total is " + grandTotal.ToString());
        Console.ReadKey();

        Account acct000 = new Savings();
    }
Пример #15
0
        static void Main(string[] args)
        {
            string  userChoice;
            decimal amount;
            string  userName = "";

            Checking checkingAccount = new Checking(800.00m, userName);
            Savings  savingsAccount  = new Savings(60000.00m, userName);
            Reserve  reserveAccount  = new Reserve(80000.00m, userName);

            //This Project is a virtual Bank called Uenhang Bank. The user has access to three types of banking accounts Checking, Savings and Reserve.

            Console.WriteLine("\t ~ Welcome to Unhaeng Bank ~");
            Console.WriteLine();
            Console.WriteLine("Please enter your name to continue:");
            Console.WriteLine();
            userName = Console.ReadLine();
            checkingAccount.UserName = userName;
            savingsAccount.UserName  = userName;
            reserveAccount.UserName  = userName;
            Console.Clear();

            Console.WriteLine();
            Console.WriteLine("\t ~Unhaeng Bank ~");
            Console.WriteLine("Welcome back " + userName);
            Console.WriteLine();

            // The user chooses actions from a list with 5 options. They can view client informaiton , view their updated account balances or complete a Deposit or Withdraw action from any of 3 accounts.
            //The menu consists of 5 main options set as if/else statements and each of those 5 options has nested if/else statments that correspond with the action
            //the user would like to take (either deposit or withdraw). The entire program is wrapped in a do/while loop. While the menue is set in an array.
            do
            {
                Console.WriteLine();
                Console.WriteLine("Please select an option to continue");
                Console.WriteLine("\n Option Menu:\nPress 1 : to View Client Information\nPress 2 : for Account Balances \nPress 3 : for Checking Account \nPress 4 : for Savings Account");
                Console.WriteLine("Press 5 : for Reserve Account\n Press 6 to exit");
                userChoice = Console.ReadLine();
                Console.WriteLine();
                {
                    string[] menuOption = new string[5];

                    menuOption[0] = "1";
                    menuOption[1] = "2";
                    menuOption[2] = "3";
                    menuOption[3] = "4";
                    menuOption[4] = "5";
//Client Information
                    if (userChoice == "1")
                    {
                        Console.WriteLine("Patron Information:");
                        Console.WriteLine("Account Number: 555555");
                        Console.WriteLine(userName);
                        Console.WriteLine("Address:\n900 Cleveland Rd.\nSeoul, SK 10004");
                        Console.WriteLine();
                        System.Threading.Thread.Sleep(3000);
                        Console.Clear();
//Account Balances
                    }
                    else if (userChoice == "2")
                    {
                        Console.WriteLine();
                        Console.WriteLine("Your Current Balances:");
                        Console.WriteLine();
                        Console.WriteLine("Checking Balance: {0:C}", checkingAccount.Balance);
                        Console.WriteLine("Savings Balance : {0:C}", savingsAccount.Balance);
                        Console.WriteLine("Reserve Balance : {0:C}", reserveAccount.Balance);
                        System.Threading.Thread.Sleep(3000);
                        Console.Clear();
                    }
//Checking Account
                    else if (userChoice == "3")
                    {
                        Console.WriteLine();
                        Console.WriteLine("CHECKING ACCOUNT:");
                        Console.WriteLine("Press 1: to DEPOSIT\nPress 2: to WITHDRAW");
                        userChoice = Console.ReadLine();
                        Console.Clear();

                        if (userChoice == "1")
                        {
                            Console.WriteLine("How much would you like to DEPOSIT?");
                            try
                            {
                                amount = decimal.Parse(Console.ReadLine());
                                checkingAccount.Deposit(amount);
                                System.Threading.Thread.Sleep(3000);
                            }
                            catch (Exception)
                            { }
                        }
                        else if (userChoice == "2")
                        {
                            Console.WriteLine("How much would you like to withdraw?");
                            try
                            {
                                amount = decimal.Parse(Console.ReadLine());
                                checkingAccount.Withdraw(amount);
                                System.Threading.Thread.Sleep(3000);
                            }
                            catch (Exception)
                            { }
                        }
                        else
                        {
                            Console.WriteLine("Please enter a valid number");
                            System.Threading.Thread.Sleep(2000);
                        }
                    }
//Savings Account
                    else if (userChoice == "4")

                    {
                        Console.WriteLine();
                        Console.WriteLine("SAVINGS ACCOUNT");
                        Console.WriteLine("Press 1: to DEPOSIT\nPress 2: to WITHDRAW");
                        userChoice = Console.ReadLine();
                        Console.Clear();

                        if (userChoice == "1")
                        {
                            Console.WriteLine("How much would you like to DEPOSIT?");
                            try
                            {
                                amount = decimal.Parse(Console.ReadLine());
                                savingsAccount.Deposit(amount);
                                System.Threading.Thread.Sleep(3000);
                            }
                            catch (Exception)
                            { }
                        }
                        else if (userChoice == "2")
                        {
                            Console.WriteLine("How much would you like to withdraw?");
                            try
                            {
                                amount = decimal.Parse(Console.ReadLine());
                                savingsAccount.Withdraw(amount);
                                System.Threading.Thread.Sleep(3000);
                            }
                            catch (Exception)
                            { }
                        }
                        else
                        {
                            Console.WriteLine("Invalid Option");
                            System.Threading.Thread.Sleep(2000);
                        }
                    }
                    //Reserve Account
                    else if (userChoice == "5")
                    {
                        Console.WriteLine();
                        Console.WriteLine("RESERVE ACCOUNT");
                        Console.WriteLine("Press 1: to DEPOSIT\nPress 2: to WITHDRAW");
                        userChoice = Console.ReadLine();
                        Console.Clear();

                        if (userChoice == "1")
                        {
                            Console.WriteLine("How much would you like to DEPOSIT?");
                            try
                            {
                                amount = decimal.Parse(Console.ReadLine());
                                reserveAccount.Withdraw(amount);
                                System.Threading.Thread.Sleep(3000);
                            }
                            catch (Exception)
                            { }
                        }
                        else if (userChoice == "2")
                        {
                            try
                            {
                                Console.WriteLine("How much would you like to withdraw?");
                                amount = decimal.Parse(Console.ReadLine());
                                reserveAccount.Withdraw(amount);
                                System.Threading.Thread.Sleep(3000);
                            }
                            catch (Exception)
                            { }
                        }
                        else
                        {
                            Console.WriteLine("Invalid Option");
                            System.Threading.Thread.Sleep(2000);
                        }
                    }
//Exit Program
                    else if (userChoice == "6")
                    {
                        Console.WriteLine("Logging out");
                        System.Threading.Thread.Sleep(2000);
                        Console.Clear();
                    }
                    else
                    {
                        Console.WriteLine("Please Enter a valid number from the option list");
                        System.Threading.Thread.Sleep(2000);
                        Console.Clear();
                    }
                }
            } while (userChoice != "6");
        }
Пример #16
0
        static int Main(string[] args)
        {
            //Account acct1 = new Account();
            //acct1.Id = 1;
            //acct1.Description = "My first checking account";
            //acct1.Balance = 0.0;
            //acct1.Owner = new Customer(100, "Greg Doud");
            //Console.WriteLine(acct1.ToPrint());

            //acct1.Deposit(5.00);
            //Console.WriteLine(acct1.ToPrint());

            //acct1.Deposit(-5.00);
            //Console.WriteLine(acct1.ToPrint());

            //acct1.Withdraw(5000.00);
            //Console.WriteLine(acct1.ToPrint());

            //Savings sav2 = new Savings();
            //sav2.Id = 2;
            //sav2.Description = "My first savings account";
            //sav2.Balance = 0.0;
            //sav2.Owner = new Customer(101, "Lisa S.");
            //sav2.IntRate = 0.12;

            //sav2.Deposit(1000.00);
            //Console.WriteLine(sav2.ToPrint());

            //Checking chk3 = new Checking();
            //chk3.Id = 3;
            //chk3.Description = "My first checking account";
            //chk3.Balance = 0.0;
            //chk3.Owner = new Customer(102, "Denise B.");

            //chk3.Deposit(2000.00);
            //Console.WriteLine(chk3.ToPrint());

            //// print out monthly statement

            Checking chka = new Checking();

            chka.Id          = 3;
            chka.Description = "My first checking account";
            chka.Balance     = 0.0;
            chka.Owner       = new Customer(103, "Kim P.");

            chka.Deposit(2000.00);

            Checking chkb = new Checking();

            chkb.Id          = 3;
            chkb.Description = "My second checking account";
            chkb.Balance     = 0.0;
            chkb.Owner       = new Customer(103, "Kim P.");

            chkb.Deposit(2000.00);

            Savings sava = new Savings();

            sava.Id          = 2;
            sava.Description = "My first savings account";
            sava.Balance     = 0.0;
            sava.Owner       = new Customer(103, "Kim P.");
            sava.IntRate     = 0.12;

            sava.Deposit(1000.00);

            Investment inv1 = new Investment();

            inv1.Deposit(500.00);

            IAccountStatement[] accounts = { chka, chkb, sava, inv1 };

            double grandTotal = 0;

            foreach (IAccountStatement acct in accounts)
            {
                double acctBalance = acct.GetBalance();
                grandTotal = grandTotal + acctBalance;
                Console.WriteLine(acct.ToPrint());
            }
            Console.WriteLine("Grand total is " + grandTotal.ToString());


            Savings s = new Savings();

            Account s1 = new Savings();

            Account c = new Checking();



            Console.ReadKey();
            return(0);
        }