Пример #1
0
        static void Main(string[] args)
        {
            // Create an instance of each Account / Instantiate Accounts
            CheckingAccount Checking = new CheckingAccount();
            ReserveAccount  Reserve  = new ReserveAccount();
            SavingsAccount  Savings  = new SavingsAccount();

            //  Instantiate StreamWriter for each account & to write to a file
            StreamWriter wChecking = new StreamWriter("CheckingAccount.txt");
            StreamWriter wReserve  = new StreamWriter("ReserveAccount.txt");
            StreamWriter wSavings  = new StreamWriter("SavingsAccount.txt");

            Console.WriteLine("Welcome to My Bank Account");
            Console.WriteLine("Type your First Name");
            string accountHolderFirstName = Console.ReadLine();

            Console.WriteLine("Type your Last Name");
            string accountHolderLastName = Console.ReadLine();
            string fullAccountHolderName = string.Concat(accountHolderFirstName, "  ", accountHolderLastName);

            {   // do-while loop
                int usersNumber = 0;
                do
                {
                    Console.WriteLine(" View Customer Information: choose 1 ");
                    Console.WriteLine(" View Checking Account Balance: choose 2 ");
                    Console.WriteLine(" View Reserve Account Balance: choose 3 ");
                    Console.WriteLine(" View Savings Account Balance: choose 4 ");
                    Console.WriteLine(" Make a Deposit into an Account: choose 5 ");
                    Console.WriteLine(" Make a Withdrawal from an Account: choose 6 ");
                    Console.WriteLine(" QUIT / EXIT Bank Account Program: choose 7 ");
                    Console.WriteLine(" TYPE your choice as a number 1, 2, 3, 4, 5, 6, or 7 ");
                    string usersResponse = Console.ReadLine();
                    usersNumber = Convert.ToInt32(usersResponse);

                    switch (usersNumber)
                    {
                    case 1:
                        Checking.BankAccountInfo();
                        break;

                    case 2:
                        Checking.AccountBalance();
                        break;

                    case 3:
                        Reserve.AccountBalance();
                        break;

                    case 4:
                        Savings.AccountBalance();
                        break;

                    case 5:
                        Console.WriteLine(" Which Account would you like to make a Deposit ");
                        Console.WriteLine(" Checking Account (Deposit): choose 1 ");
                        Console.WriteLine(" Reserve Account (Deposit): choose 2 ");
                        Console.WriteLine(" Savings Account (Deposit): choose 3 ");
                        int userChoice = Convert.ToInt32(Console.ReadLine());

                        Console.WriteLine("How Much would you like to Deposit");
                        decimal deposit = Convert.ToDecimal(Console.ReadLine());
                        switch (userChoice)
                        {
                        case 1:
                            Checking.Deposit(deposit);
                            Console.WriteLine(" Checking Account New Balance: ${0} ", Checking.CheckingAccountBalance);
                            using (wChecking)
                            {
                                wChecking.WriteLine(fullAccountHolderName);
                                wChecking.WriteLine(" Checking Account No.: {0} ", Checking.CheckingAccountNo);
                                wChecking.WriteLine(DateTime.Now);
                                wChecking.WriteLine(" + :$ {0}", deposit);
                                wChecking.WriteLine(" Checking Account New Balance: {0} ", Checking.CheckingAccountBalance);
                            }
                            break;

                        case 2:
                            Reserve.Deposit(deposit);
                            Console.WriteLine(" Reserve Account New Balance: ${0} ", Reserve.ReserveAccountBalance);
                            using (wReserve)
                            {
                                wReserve.WriteLine(fullAccountHolderName);
                                wReserve.WriteLine(" Reserve Account No.: {0} ", Reserve.ReserveAccountNo);
                                wReserve.WriteLine(DateTime.Now);
                                wReserve.WriteLine(" + :$ {0}", deposit);
                                wReserve.WriteLine(" Reserve Account New Balance: ${0} ", Reserve.ReserveAccountBalance);
                            }
                            break;

                        case 3:
                            Savings.Deposit(deposit);
                            Console.WriteLine(" Savings Account New Balance: ${0} ", Savings.SavingsAccountBalance);
                            using (wSavings)
                            {
                                wSavings.WriteLine(fullAccountHolderName);
                                wSavings.WriteLine(" Reserve Account No.: {0} ", Savings.SavingsAccountNo);
                                wSavings.WriteLine(DateTime.Now);
                                wSavings.WriteLine(" + :$ {0}", deposit);
                                wSavings.WriteLine(" Savings Account New Balance: ${0} ", Savings.SavingsAccountBalance);
                            }
                            break;

                        default:

                            Console.WriteLine(" Invalid selection ");
                            Console.WriteLine(" Please choose Deposit option 1, 2, or, 3 ");
                            break;
                        }
                        break;

                    case 6:
                        Console.WriteLine(" Which Account would you like to make a Withdrawal from ");
                        Console.WriteLine(" Checking Account (Withdrawal): choose 1 ");
                        Console.WriteLine(" Reserve Account (Withdrawal): choose 2 ");
                        Console.WriteLine(" Savings Account (Withdrawal): choose 3 ");
                        int userOption = Convert.ToInt32(Console.ReadLine());

                        Console.WriteLine("How Much would you like to Withdraw");
                        decimal withdrawal = Convert.ToDecimal(Console.ReadLine());
                        switch (userOption)
                        {
                        case 1:
                            Checking.Withdrawal(withdrawal);
                            Console.WriteLine(" Check Account New Balance: ${0} ", Checking.CheckingAccountBalance);
                            using (wChecking)
                            {
                                wChecking.WriteLine(fullAccountHolderName);
                                wChecking.WriteLine(" Checking Account No.: {0} ", Checking.CheckingAccountNo);
                                wChecking.WriteLine(DateTime.Now);
                                wChecking.WriteLine(" - :$ {0}", withdrawal);
                                wChecking.WriteLine(" Check Account New Balance: {0} ", Checking.CheckingAccountBalance);
                            }
                            break;

                        case 2:
                            Reserve.Withdrawal(withdrawal);
                            Console.WriteLine(" Reserve Account New Balance: ${0} ", Reserve.ReserveAccountBalance);
                            using (wReserve)
                            {
                                wReserve.WriteLine(fullAccountHolderName);
                                wReserve.WriteLine(" Reserve Account No.: {0} ", Reserve.ReserveAccountNo);
                                wReserve.WriteLine(DateTime.Now);
                                wReserve.WriteLine(" + :$ {0}", withdrawal);
                                wReserve.WriteLine(" Reserve Account New Balance: ${0} ", Reserve.ReserveAccountBalance);
                            }
                            break;

                        case 3:
                            Savings.Withdrawal(withdrawal);
                            Console.WriteLine(" Savings Account New Balance: ${0} ", Savings.SavingsAccountBalance);
                            using (wSavings)
                            {
                                wSavings.WriteLine(fullAccountHolderName);
                                wSavings.WriteLine(" Savings Account No.: {0} ", Savings.SavingsAccountNo);
                                wSavings.WriteLine(DateTime.Now);
                                wSavings.WriteLine(" + :$ {0}", withdrawal);
                                wSavings.WriteLine(" Savings Account New Balance: ${0} ", Savings.SavingsAccountBalance);
                            }
                            break;

                        default:

                            Console.WriteLine(" Invalid selection ");
                            Console.WriteLine(" Please choose Deposit option 1, 2, or, 3 ");
                            break;
                        }
                        break;

                    case 7:
                        Console.WriteLine(" Thank you for using My Bank Account Program ");
                        Console.WriteLine(" , use our program anytime ");
                        Environment.Exit(0);
                        break;

                    default:
                        Console.WriteLine(" Invalid Selection ");
                        Console.WriteLine(" Please choose number 1, 2, 3, 4, 5, 6, or, 7 ");
                        break;
                    }
                }while (usersNumber != 7);
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            //sign in screen
            Console.WriteLine("Welcome to Monopoly Bank! Please sign into your account by typing in your username: "******"Please type in your password: "******"Welcome to your account, {0}! Please choose from the options below by typing in the corresponding number: ", userName);

            //Creation of switch to turn program on and off
            bool program = true;

            //Creation of objects
            Account         account         = new Account(userName, password, savings, checking, reserve, withdraw, deposit);
            SavingsAccount  savingsAccount  = new SavingsAccount();
            CheckingAccount checkingAccount = new CheckingAccount();
            ReserveAccount  reserveAccount  = new ReserveAccount();

            //Begin running actual program
            while (program == true)
            {
                //application menu
                Console.WriteLine("1.) User information");
                Console.WriteLine("2.) Check balance");
                Console.WriteLine("3.) Withdraw funds");
                Console.WriteLine("4.) Deposit funds");
                Console.WriteLine("5.) Exit");

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

                //User's choice from menu prompts corresponding methods
                switch (userInput)
                {
                case 1:
                    //User info option
                    Console.WriteLine("What would you like to do? Enter a number to choose:");
                    Console.WriteLine("1.) View User Info:");
                    Console.WriteLine("2.) Edit Password:"******"What else would you like to do? Please choose from the following options: ");
                    break;

                case 2:
                    //ask user if viewing checking savings, checking or reserve balance
                    Console.WriteLine("What balance would you like to check? Please choose from the numbers below:");
                    Console.WriteLine("1.) Checking:");
                    Console.WriteLine("2.) Savings:");
                    Console.WriteLine("3.) Reserve:");
                    int balanceChoice = int.Parse(Console.ReadLine());
                    if (balanceChoice == 1)
                    {       //view checking account balance
                        checkingAccount.ShowBalance(checking);
                    }
                    if (balanceChoice == 2)
                    {
                        //view savings account balance
                        savingsAccount.AddInterest(savings);
                        savingsAccount.ShowBalance(savings);
                    }
                    if (balanceChoice == 3)
                    {
                        //view reserve account balance
                        reserveAccount.ShowBalance(reserve);
                    }
                    Console.WriteLine("What else would you like to do? Please choose from the following options: ");
                    break;

                case 3:
                    //Ask user where they would like to withdraw funds from
                    Console.WriteLine("Where would you like to withdraw from? Please choose from the numbers below:");
                    Console.WriteLine("1.) Checking:");
                    Console.WriteLine("2.) Savings:");
                    Console.WriteLine("3.) Reserve:");
                    int withdrawChoice = int.Parse(Console.ReadLine());
                    if (withdrawChoice == 1)
                    {       //checking account withdraw
                        checking = checkingAccount.MakeWithdraw(withdraw, checking);
                    }
                    if (withdrawChoice == 2)
                    {
                        //savings account withdraw
                        savings = savingsAccount.AddInterest(savings);
                        savings = savingsAccount.MakeWithdraw(withdraw, savings);
                    }
                    if (withdrawChoice == 3)
                    {
                        //reserve account withdraw
                        reserve = reserveAccount.MakeWithdraw(withdraw, reserve);
                    }
                    Console.WriteLine("What else would you like to do? Please choose from the following options: ");
                    break;

                case 4:
                    //ask user which account to deposit funds to
                    Console.WriteLine("Which account would you like to deposit into? Please choose from the numbers below:");
                    Console.WriteLine("1.) Checking:");
                    Console.WriteLine("2.) Savings:");
                    Console.WriteLine("3.) Reserve:");
                    int depositChoice = int.Parse(Console.ReadLine());
                    if (depositChoice == 1)
                    {       //checking account withdraw
                        checking = checkingAccount.MakeDeposit(deposit, checking);
                    }
                    if (depositChoice == 2)
                    {
                        //savings account witdraw
                        savings = savingsAccount.AddInterest(savings);
                        savings = savingsAccount.MakeDeposit(deposit, savings);
                    }
                    if (depositChoice == 3)
                    {
                        //reserve account withdraw
                        reserve = reserveAccount.MakeDeposit(deposit, reserve);
                    }
                    Console.WriteLine("What else would you like to do? Please choose from the following options: ");
                    break;

                case 5:
                    //Exit program
                    Console.WriteLine("Thank you! Have a great day!");
                    program = false;
                    break;

                default:
                    //Catches any user input that is NOT 1-5
                    Console.WriteLine("Oops! I didn't understand you. Please try again. Please choose from the list below: ");
                    break;
                }
            }
        }
Пример #3
0
        static void Main(string[] args)
        {
            //open streamwriter to create text file
            StreamWriter accountReserve  = new StreamWriter("ReserveAccount.txt");
            StreamWriter accountSavings  = new StreamWriter("SavingsAccount.txt");
            StreamWriter accountChecking = new StreamWriter("CheckingAccount.txt");

            //ask for name

            Console.WriteLine("Please enter your name for your password.");
            string holderName = Console.ReadLine();

            Console.Clear();

            //create objects to use classes
            SavingsAccount  savings  = new SavingsAccount(holderName);
            CheckingAccount checking = new CheckingAccount(holderName);
            ReserveAccount  reserve  = new ReserveAccount(holderName);

            //beginning of text file for each account
            accountChecking.WriteLine("Account Holder: " + holderName);
            accountChecking.WriteLine("Account Number: " + checking.AccountNumber);
            accountChecking.WriteLine("Account Type: Checking Account");
            accountChecking.WriteLine("Account Balance: " + checking.AccountBalance);

            accountSavings.WriteLine("Account Holder: " + holderName);
            accountSavings.WriteLine("Account Number: " + savings.AccountNumber);
            accountSavings.WriteLine("Account Type: Savings Account");
            accountSavings.WriteLine("Account Balance: " + savings.AccountBalance);

            accountReserve.WriteLine("Account Holder: " + holderName);
            accountReserve.WriteLine("Account Number: " + reserve.AccountNumber);
            accountReserve.WriteLine("Account Type: Reserve Account");
            accountReserve.WriteLine("Account Balance: " + reserve.AccountBalance);

            //loop for menu
            while (true)
            {
                //menu
                Console.WriteLine("Welcome! What would you like to do?");
                Console.WriteLine("1: View Client Information");
                Console.WriteLine("View Account Balance of:");
                Console.WriteLine("\t2: Checking Account");
                Console.WriteLine("\t3: Savings Account");
                Console.WriteLine("\t4: Reserve Account");
                Console.WriteLine("5: Deposit Funds");
                Console.WriteLine("6: Withdrawal Funds");
                Console.WriteLine("7: Exit");

                //user choose for which action on menu
                int action = int.Parse(Console.ReadLine());

                Console.Clear();

                //action for what happens when the user makes a choose
                switch (action)
                {
                case 1:
                    //calls method from account to show client info
                    savings.ClientInfo();
                    break;

                case 2:
                    //calls method from checking to view balance
                    checking.ViewAccountBalance();
                    break;

                case 3:
                    //views savings balance
                    savings.ViewAccountBalance();
                    break;

                case 4:
                    //views reserve balance
                    reserve.ViewAccountBalance();
                    break;

                case 5:
                    //asks user where they want to make a deposit and the adds funds to that account
                    Console.WriteLine("Where would you like to make a deposit?");
                    Console.WriteLine("1: Checking Account");
                    Console.WriteLine("2: Savings Account");
                    Console.WriteLine("3: Reserve Account");

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

                    Console.WriteLine("How much would you like to deposit?");

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

                    switch (choice)
                    {
                    case 1:
                        checking.Deposit(deposit);
                        Console.WriteLine("The new balance is " + checking.AccountBalance);
                        accountChecking.WriteLine("+ " + deposit + " " + DateTime.Now);
                        accountChecking.WriteLine("Account Balance: " + checking.AccountBalance);
                        break;

                    case 2:
                        savings.Deposit(deposit);
                        Console.WriteLine("The new balance is " + savings.AccountBalance);
                        accountSavings.WriteLine("+ " + deposit + " " + DateTime.Now);
                        accountSavings.WriteLine("Account Balance: " + savings.AccountBalance);
                        break;

                    case 3:
                        reserve.Deposit(deposit);
                        Console.WriteLine("The new balance is " + reserve.AccountBalance);
                        accountReserve.WriteLine("+ " + deposit + " " + DateTime.Now);
                        accountReserve.WriteLine("Account Balance: " + reserve.AccountBalance);
                        break;

                    default:
                        break;
                    }
                    break;

                case 6:
                    //asks user where to withdrawal and then takes funds from that account
                    Console.WriteLine("Where would you like to make a withdrawal?");
                    Console.WriteLine("1: Checking Account");
                    Console.WriteLine("2: Savings Account");
                    Console.WriteLine("3: Reserve Account");

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

                    Console.WriteLine("How much would you like to withdrawal?");

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

                    switch (pick)
                    {
                    case 1:
                        checking.Withdrawal(withdrawal);
                        Console.WriteLine("The new balance is " + checking.AccountBalance);
                        accountChecking.WriteLine("- " + withdrawal + " " + DateTime.Now);
                        accountChecking.WriteLine("Account Balance: " + checking.AccountBalance);
                        break;

                    case 2:
                        savings.Withdrawal(withdrawal);
                        Console.WriteLine("The new balance is " + savings.AccountBalance);
                        accountSavings.WriteLine("- " + withdrawal + " " + DateTime.Now);
                        accountSavings.WriteLine("Account Balance: " + savings.AccountBalance);
                        break;

                    case 3:
                        reserve.Withdrawal(withdrawal);
                        Console.WriteLine("The new balance is " + reserve.AccountBalance);
                        accountReserve.WriteLine("- " + withdrawal + " " + DateTime.Now);
                        accountReserve.WriteLine("Account Balance: " + reserve.AccountBalance);
                        break;
                    }
                    break;

                case 7:
                    //quits to ask if they want to do anything else
                    break;

                default:
                    //quits to ask if they want to do anything else
                    break;
                }


                Console.WriteLine("Would you like to do something else? Y or N?");
                string yesOrNo = Console.ReadLine();
                if (yesOrNo.ToLower() == "y")
                {
                    //clears console and goes back to the menu since in a loop
                    Console.Clear();
                }
                else
                {
                    //breaks out of loop and quits the program
                    Console.Clear();
                    break;
                }
            }

            //closes the streamwriters
            accountReserve.Close();
            accountSavings.Close();
            accountChecking.Close();

            Quit();
        }