Ejemplo n.º 1
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();
            }
        }
Ejemplo n.º 2
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();
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
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();
        }
Ejemplo n.º 6
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");
        }
Ejemplo n.º 7
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);
        }