Exemplo n.º 1
0
 public decimal SavingsWithdraw(decimal deposit)
 {
     SavingsAccount.Withdraw(deposit);
     return(SavingsAccount.Balance);
 }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            int selection;

            //Instantiate objects
            Client          johnSmith  = new Client();
            CheckingAccount jsChecking = new CheckingAccount();
            SavingsAccount  jsSavings  = new SavingsAccount();

            //Ask for user input
            Console.WriteLine("Hello and welcome to Lehman Brothers. \nHere you can view your account information.");
            Console.WriteLine("It is 2008 and we promise that subprime lending is always a wise investment.");
            Console.WriteLine("We also guarantee to never file for bankruptcy.");

            do
            {
                Console.WriteLine("\nPlease select from the following options: \n1. View Client Information\n2. View Account Balance\n3. Deposit Funds\n4. Withdraw Funds\n5. Exit");

                //Variables based on user input
                selection = int.Parse(Console.ReadLine());
                char account;

                if (selection == 1)
                {
                    Console.WriteLine(johnSmith.GetClientInfo());
                }
                if (selection == 2)
                {
                    Console.WriteLine("Which account would you like to view the balance of?");
                    Console.WriteLine("Please select:\na. Checking Account\nb. Savings Account");
                    account = char.Parse(Console.ReadLine().ToLower());
                    if (account == 'a')
                    {
                        jsChecking.GetBalance();
                    }
                    if (account == 'b')
                    {
                        jsSavings.GetBalance();
                    }
                }
                if (selection == 3)
                {
                    Console.WriteLine("To which account would you like to make a deposit?");
                    Console.WriteLine("Please select:\na. Checking Account\nb. Savings Account");
                    account = char.Parse(Console.ReadLine().ToLower());
                    if (account == 'a')
                    {
                        jsChecking.Deposit();
                    }
                    if (account == 'b')
                    {
                        jsSavings.Deposit();
                    }
                }
                if (selection == 4)
                {
                    Console.WriteLine("From which account would you like to make a withdrawal?");
                    Console.WriteLine("Please select:\na. Checking Account\nb. Savings Account");
                    account = char.Parse(Console.ReadLine().ToLower());
                    if (account == 'a')
                    {
                        jsChecking.Withdraw();
                    }
                    if (account == 'b')
                    {
                        jsSavings.Withdraw();
                    }
                }
            }while (selection != 5);
        }
Exemplo n.º 3
0
 //Transfer Money from checking to savings.
 private float TransferChecking(SavingsAccount saving, CheckingAccount checking, float amount)
 {
     checking.accountMoney -= amount;
     saving.accountMoney   += amount;
     return(checking.accountMoney);
 }
Exemplo n.º 4
0
 public decimal SavingsDeposit(decimal deposit)
 {
     SavingsAccount.Deposit(deposit);
     return(SavingsAccount.Balance);
 }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            Console.Clear();
            Intro    intro1   = new Intro();    //Instantiated an object for the Sign in page
            MainMenu menu1    = new MainMenu(); //Instantiated an object for main menu
            MainMenu CheckSav = new MainMenu(); //Instantiated an object for the different
                                                //checking and saving menus

            Client client1 = new Client("Capone", "Al", 6, "Feet Under Park",
                                        "212-001-0001", 0001, 1899, 1292094, 1359982); //Instantiated a new client object


            CheckingAccount account3 = new CheckingAccount(); //Instantiated a new checking acct object
            SavingsAccount  account2 = new SavingsAccount();  //Instantiated a new savings acct object

            account3.AccountType = "Checking";
            account2.AccountType = "Savings";
            double deposit;
            double withdraw;
            string selectionKey = " ";
            int    number       = 0;

            intro1.Introduction();  //Called the sign on screen method

            do                      //ran entire program through a do-while loop, so the user can not exit until
            {                       //pressing the number 5
                Console.Clear();
                menu1.MenuMethod(); //called the method for the sign on page
                selectionKey = Console.ReadLine();
                Console.Clear();
                bool intResultTryParse = int.TryParse(selectionKey, out number);

                if (selectionKey == "1")  // used an If Else-If condition for the 5 choices on main menu
                {
                    client1.ClientInfo(); //called the method from the client class for their info
                    AccountAnswer();
                }
                else if (selectionKey == "2")
                {
                    CheckSav.ChckSavMenu(); // this method calls the menu to choose between checking and savings
                    selectionKey = Console.ReadLine();
                    Console.Clear();

                    switch (selectionKey)  // used the switch case for user to choose between checking/savings
                    {
                    case "a":
                        menu1.TopLine();                                              //called this method several times during program for top line on screen
                        Console.WriteLine("\n\n\t\t\t\tChecking Account Number #" + client1.SearchForCheckAcctNum() + "\n\n\t\t\t\tBalance: "
                                          + account3.GetChkBalance().ToString("C2")); //used this abstract method from the parent account of the Checking Account Class to get the account number
                                                                                      //also used the method from the Checking Account Class to get the account balance.
                        menu1.BottomLine();                                           //called this method several times during program for bottom line on screen
                        AccountAnswer();                                              //Method from below to ask user to press any key to continue
                        break;


                    case "b":
                        menu1.TopLine();
                        Console.WriteLine("\n\n\t\t\t\tSavings Account Number #" + client1.SearchForSavAcctNum() + "\n\n\t\t\t\tBalance: "
                                          + account2.GetSavBalance().ToString("C2")); //used this abstract method from the parent account of the Savings Account Class to get the account number
                                                                                      //also used the method from the Savings Account Class to get the account balance.
                        menu1.BottomLine();
                        AccountAnswer();
                        break;

                    default:
                        break;
                    }
                }
                else if (selectionKey == "3")
                {
                    CheckSav.ChckSavMenuDeposit(); //different method for menu selection
                    string checkOrSave = Console.ReadLine().ToLower();
                    Console.Clear();
                    switch (checkOrSave) //used a switch case for user to pick between check/savings
                    {
                    case "a":            //this is for checking
                        Console.Clear();

                        menu1.TopLine();
                        Console.WriteLine("\n\n\t\t\tHow much would you like to deposit " +
                                          "into your checking account?");

                        Console.Write("\n\n\t\t\tDeposit Amount: ");
                        deposit = double.Parse(Console.ReadLine());
                        menu1.BottomLine();

                        Console.Clear();
                        menu1.TopLine();
                        account3.CheckingAccountBalance = account3.AddToChecking(deposit);    //used this operation to save the checking account balance
                        Console.WriteLine("\n\n\t\t\tYour New Balance for Checking Account #" + client1.SearchForCheckAcctNum() + " is: " +
                                          account3.CheckingAccountBalance.ToString("C2"));
                        menu1.BottomLine();

                        AccountAnswer();
                        break;

                    case "b":      //did the same thing as case "a" but for savings
                        Console.Clear();

                        menu1.TopLine();
                        Console.WriteLine("\n\n\t\t\tHow much would you like to deposit " +
                                          "into your savings account?");

                        Console.Write("\n\n\t\t\tDeposit Amount: ");
                        deposit = double.Parse(Console.ReadLine());
                        menu1.BottomLine();

                        Console.Clear();
                        menu1.TopLine();
                        account2.SavingsAccountBalance = account2.AddToSavingsAccount(deposit);    //used this to save the savings balance
                        Console.WriteLine("\n\n\t\t\tYour New Balance for Savings Account #" + client1.SearchForSavAcctNum() + " is: " +
                                          account2.SavingsAccountBalance.ToString("C2"));
                        menu1.BottomLine();

                        AccountAnswer();
                        break;


                    default:
                        AccountAnswer();
                        break;
                    }
                }
                else if (selectionKey == "4")
                {
                    CheckSav.ChckSavMenuWithdraw(); //different method for withdrawal selection
                    string checkOrSave = Console.ReadLine().ToLower();
                    Console.Clear();
                    switch (checkOrSave) //same case for withdrawals as was for checking
                    {
                    case "a":
                        Console.Clear();
                        menu1.TopLine();
                        Console.WriteLine("\n\n\t\t\tHow much would you like to withdraw today " +
                                          "from your checking account?");
                        Console.Write("\n\n\t\t\tWithdraw Amount: ");
                        withdraw = double.Parse(Console.ReadLine());
                        menu1.BottomLine();
                        Console.Clear();

                        do      //used this conditional to check for insufficient funds
                        {
                            if (withdraw > account3.CheckingAccountBalance)
                            {
                                menu1.TopLine();
                                Console.WriteLine("\n\n\t\t\t\t\t\tINSUFFICIENT FUNDS");
                                Console.WriteLine("\n\n\n\t\t\t\tAmount available for withdrawal: " +
                                                  account3.CheckingAccountBalance.ToString("C2"));
                                Console.Write("\n\t\t\t\tPlease enter a different amount.\n\n" +
                                              "\t\t\t\tWithdraw Amount: ");
                                withdraw = double.Parse(Console.ReadLine());
                                menu1.BottomLine();

                                Console.Clear();
                            }
                        } while (withdraw > account3.CheckingAccountBalance);

                        account3.CheckingAccountBalance = account3.SubtractFromChecking(withdraw);
                        //if sufficient funds then I subtracted from the account  ^^^
                        menu1.TopLine();
                        Console.WriteLine("\n\n\t\t\tYour New Balance: " +
                                          account3.CheckingAccountBalance.ToString("C2"));
                        menu1.BottomLine();

                        AccountAnswer();
                        break;

                    case "b":
                        double minSavBal = account2.SavingsAccountBalance - 500;     //equation to find minimum balance
                        menu1.TopLine();
                        Console.WriteLine("\n\n\t\t\tHow much would you like to withdraw " +
                                          "today from your savings account?");
                        Console.Write("\n\n\t\t\tWithdraw Amount: ");
                        withdraw = double.Parse(Console.ReadLine());
                        menu1.BottomLine();

                        Console.Clear();
                        do        // used this conditional to check for insufficient funds
                        {
                            if (withdraw > minSavBal)
                            {
                                menu1.TopLine();
                                Console.WriteLine("\n\n\t\t\t\t\t\tINSUFFICIENT FUNDS");
                                Console.WriteLine("\n\n\n\t\t\t\tAmount available for withdrawal: " +
                                                  minSavBal.ToString("C2"));
                                Console.Write("\n\t\t\t\tPlease enter a different amount.\n\n" +
                                              "\t\t\t\tWithdraw Amount: ");
                                withdraw = double.Parse(Console.ReadLine());
                                menu1.BottomLine();
                                Console.Clear();
                            }
                        } while (withdraw > minSavBal);

                        account2.SavingsAccountBalance = account2.SubtractFromSavings(withdraw);
                        //if sufficient funds then I subtracted from the account  ^^^
                        menu1.TopLine();
                        Console.WriteLine("\n\n\t\t\tYour New Balance: " +
                                          account2.SavingsAccountBalance.ToString("C2"));
                        menu1.BottomLine();

                        AccountAnswer();
                        break;

                    default:
                        Console.WriteLine("\n\n\t\t\tContinue");
                        break;
                    }
                }
                else if (selectionKey == "5")
                {
                    Exit();
                }
                else
                {
                    AccountAnswer();
                }
            } while (selectionKey != "5");
        }
Exemplo n.º 6
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;
                }
            }
        }
Exemplo n.º 7
0
 public static void Main(string[] args)
 {
     // Console.WriteLine("Hello World!");
     CheckingAccount checking = new CheckingAccount(45.99f);
     SavingsAccount  savings  = new SavingsAccount(0.00f);
 }
Exemplo n.º 8
0
        static void Main(string[] args)
        {
            // STRETCH TASK - started thinking of ideas for how to accomplish stretch task but did not finished

            //string clientUserName;

            //Console.WriteLine("Please enter your username.");
            //clientUserName = Console.ReadLine();

            //Dictionary<string, string> userNames = new Dictionary<string, string>()
            //{
            //    { "username1", "client1" }, // { "key", "value" }
            //    { "username2", "client2" },
            //    { "Dusername3", "client3" },
            //    { "LLusername4", "client4" }
            //};

            //foreach (KeyValuePair<string, string> userName in userNames)
            //{
            //    if (clientUserName == userNames.Key) // if user name entered is equal to any of the keys in the dictionary
            //    {
            //        continue;
            //    }
            //    else
            //    {
            //        Console.WriteLine("Incorrect user name.");
            //    }

            //}

            string returnMenuOptionSelected;

            Client          client1          = new Client();                 // instantiate client object
            CheckingAccount checkingAccount1 = new CheckingAccount(20000d);  // instantiate checking account object with starting balance
            SavingsAccount  savingsAccount1  = new SavingsAccount(1000000d); // instantiate savings account object with starting balance
            MenuOutputs     accountTypeMenu  = new MenuOutputs();            // instantiate account type menu object
            MenuOutputs     invalidEntry     = new MenuOutputs();            // instantiate invalid entry object
            MenuOutputs     exitRepsonse     = new MenuOutputs();            // instantiate exit response object

            do
            {
                Console.WriteLine("Choose an option from the menu below:");
                string[] mainMenu = { "1. View Client Information", "2. View Account Balance", "3. Deposit Funds", "4. Withdraw Funds", "5. Exit" };
                Console.WriteLine(mainMenu[0]);
                Console.WriteLine(mainMenu[1]);
                Console.WriteLine(mainMenu[2]);
                Console.WriteLine(mainMenu[3]);
                Console.WriteLine(mainMenu[4]);

                string mainMenuOptionSelected = Console.ReadLine();

                if (mainMenuOptionSelected == "1")      // View Client Information
                {
                    client1.View();                     // calls View from Client class
                }
                else if (mainMenuOptionSelected == "2") // View Account Balance
                {
                    accountTypeMenu.CreateAccountTypeMenu();

                    string accountInformationMenuOptionSelected = Console.ReadLine().ToLower();

                    if (accountInformationMenuOptionSelected == "a")      // Checking Account
                    {
                        checkingAccount1.View();                          // calls View from CheckingAccount class
                    }
                    else if (accountInformationMenuOptionSelected == "b") // Savings Account
                    {
                        savingsAccount1.View();                           // calls View from SavingsAccount class
                    }
                    else
                    {
                        invalidEntry.InvalidEntryResponse();
                    }
                }
                else if (mainMenuOptionSelected == "3") // Deposit Funds
                {
                    accountTypeMenu.CreateAccountTypeMenu();

                    string depositFundsMenuOptionSelected = Console.ReadLine().ToLower();

                    if (depositFundsMenuOptionSelected == "a")      // Checking Account
                    {
                        checkingAccount1.Deposit();                 // calls Deposit from CheckingAccount class
                    }
                    else if (depositFundsMenuOptionSelected == "b") // Savings Account
                    {
                        savingsAccount1.Deposit();                  // calls Deposit from SavingsAccount class
                    }
                    else
                    {
                        invalidEntry.InvalidEntryResponse();
                    }
                }
                else if (mainMenuOptionSelected == "4") // Withdraw Funds
                {
                    accountTypeMenu.CreateAccountTypeMenu();

                    string withdrawFundsMenuOptionSelected = Console.ReadLine().ToLower();

                    if (withdrawFundsMenuOptionSelected == "a")                                // Checking Account
                    {
                        Console.WriteLine("Current balance: $" + checkingAccount1.Withdraw()); // calls Deposit from CheckingAccount class
                    }
                    else if (withdrawFundsMenuOptionSelected == "b")                           // Savings Account
                    {
                        Console.WriteLine("Current balance: $" + savingsAccount1.Withdraw());  // calls Deposit from SavingsAccount class
                    }
                    else
                    {
                        invalidEntry.InvalidEntryResponse();
                    }
                }
                else if (mainMenuOptionSelected == "5") // Exit
                {
                    exitRepsonse.ExitResponse();
                    return;
                }
                else
                {
                    invalidEntry.InvalidEntryResponse();
                }

                Console.WriteLine("Return to main menu or exit?");
                string[] returnMenu = { "1. Main Menu", "2. Exit" };
                Console.WriteLine(returnMenu[0]);
                Console.WriteLine(returnMenu[1]);
                returnMenuOptionSelected = Console.ReadLine();
                if (returnMenuOptionSelected == "2")
                {
                    exitRepsonse.ExitResponse();
                }
            }while (returnMenuOptionSelected == "1"); // returns to main menu
        }
Exemplo n.º 9
0
        public static void SavingsMenu()
        {
            bool errmenu = true;

            do
            {
                try
                {
                    SavingsAccount savings = new SavingsAccount(5, 1.00);
                    StringBuilder  sb      = new StringBuilder();
                    sb.Append("Savings Menu\n");
                    sb.Append("A. Deposit\n");
                    sb.Append("B. Withdrawal\n");
                    sb.Append("C. Close + Report\n");
                    sb.Append("R. Return to Bank Menu\n");
                    Console.WriteLine(sb.ToString());
                    string sinput = Console.ReadLine().ToUpper();
                    switch (sinput)
                    {
                    case "A":
                        bool depositerror = true;
                        do
                        {
                            try
                            {
                                Console.WriteLine("Please enter the deposit amount:");
                                string deposit      = Console.ReadLine();
                                bool   validdeposit = Double.TryParse(deposit, out double depositvalue);

                                if (validdeposit)
                                {
                                    savings.MakeDeposit(depositvalue);
                                }
                                else
                                {
                                    throw new NumberValueException("\"" + deposit + "\" is not a numeric value.");
                                }
                                depositerror = false;
                            }
                            catch (NumberValueException nex)
                            {
                                Console.WriteLine(nex.Message);
                                depositerror = true;
                            }
                        } while (depositerror);
                        break;

                    case "B":
                        bool withdrawalerror = true;
                        do
                        {
                            try
                            {
                                Console.WriteLine("Please enter the withdrawal amount:");
                                string withdrawal      = Console.ReadLine();
                                bool   validwithdrawal = Double.TryParse(withdrawal, out double withdrawalvalue);

                                if (validwithdrawal)
                                {
                                    savings.MakeDeposit(withdrawalvalue);
                                }
                                else
                                {
                                    throw new NumberValueException("\"" + withdrawal + "\" is not a numeric value.");
                                }
                                withdrawalerror = false;
                            }
                            catch (NumberValueException nex)
                            {
                                Console.WriteLine(nex.Message);
                                withdrawalerror = true;
                            }
                        } while (withdrawalerror);
                        break;

                    case "C":
                        savings.CloseAndReport();
                        break;

                    case "R":
                        MainMenu();
                        break;

                    default:
                        throw new IllegalSavingsMenuOptionException("Unkown option \"" + sinput + "\"");
                    }
                }
                catch (IllegalSavingsMenuOptionException ex)
                {
                    Console.WriteLine(ex.Message);
                }
            } while (errmenu);
        }
Exemplo n.º 10
0
        static void Main(string[] args)
        {
            //Bank Account Project
            //Ryan Sizer
            //Week 3 - 04/17/2017

            //Instantiate a new object of Client class
            Client client1 = new Client();

            //Instantiate a new object of CheckingAccount class
            CheckingAccount checking1 = new CheckingAccount("12345", "Lord Tyrion's Checking Account", 25236755.23, 77000500.51);


            //Instantiate a new object of SavingsAccount class
            SavingsAccount savings1 = new SavingsAccount("12345", "Lord Tyrion's Savings Account", 25236755.23, 77000500.51);

            //client1.DisplayClientInfo();


            //Greet the user
            Console.WriteLine("Hello, Mr. Lannister. Welcome to your Bank Account.\r\n");

            //Use a do-while loop for the menu and to keep program running until user exits
            do
            {
                //Store menu options in a string
                string menu = ("BANK OF WESTEROS" + Environment.NewLine +
                               "----------------------------------" + Environment.NewLine +
                               "- [1] View Client Information" + Environment.NewLine +
                               "- [2] View Account Balance" + Environment.NewLine +
                               "- [3] Deposit Funds" + Environment.NewLine +
                               "- [4] Withdraw Funds" + Environment.NewLine +
                               "- [5] Exit Program" + Environment.NewLine);

                //Display menu options
                Console.WriteLine(menu);

                //Store user response in a string variable
                string menuChoice = Console.ReadLine();

                //Validate if user input anything
                while (string.IsNullOrWhiteSpace(menuChoice))
                {
                    Console.Clear();
                    //Tell user what went wrong
                    Console.WriteLine("Oops! You didn't select anything.\r\nPlease select a menu option between 1 and 5: ");

                    Console.WriteLine(menu);

                    menuChoice = Console.ReadLine();
                }

                //Declare variable to hold the converted value of menu selection
                int menuInt;

                //Convert with TryParse
                int.TryParse(menuChoice, out menuInt);


                //Validate that user made a numerical choice between 1 and 5
                while (menuInt < 1 || menuInt > 5)
                {
                    Console.Clear();
                    //Tell user what went wrong
                    Console.WriteLine("Oops! You selected something other than a number between 1 and 5.\r\nPlease try again and make a menu selection between 1 and 5.");
                    Console.WriteLine(menu);
                    //Re-capture user response
                    menuChoice = Console.ReadLine();

                    //re-convert to an integer
                    int.TryParse(menuChoice, out menuInt);
                }

                Console.Clear();

                //Use switch case for user menu selections
                switch (menuInt)
                {
                //When user selects option one, client information is displayed
                case 1:

                    client1.DisplayClientInfo();
                    break;

                //When user selects option two, display submenu so they can select checkings or savings
                case 2:


                    //Store submenu in a string
                    string balanceSubMenu = ("BANK OF WESTEROS" + Environment.NewLine +
                                             "----------------------------------" + Environment.NewLine +
                                             "- [1] View Checking Account Balance" + Environment.NewLine +
                                             "- [2] View Savings Account Balance" + Environment.NewLine);
                    Console.WriteLine(balanceSubMenu);     //Display submenu to console

                    string balanceChoice = Console.ReadLine();

                    //Validate if user input anything
                    while (string.IsNullOrWhiteSpace(balanceChoice))
                    {
                        Console.Clear();
                        //Tell user what went wrong
                        Console.WriteLine("Oops! You didn't select anything.\r\nPlease select a menu option of 1 or 2: ");

                        Console.WriteLine(balanceSubMenu);

                        balanceChoice = Console.ReadLine();
                    }

                    //Declare variable to hold the converted value of menu selection
                    int balanceChoiceInt;

                    //Convert with TryParse
                    int.TryParse(balanceChoice, out balanceChoiceInt);


                    //Validate that user made a numerical choice between 1 and 5
                    while (balanceChoiceInt < 1 || balanceChoiceInt > 2)
                    {
                        Console.Clear();
                        //Tell user what went wrong
                        Console.WriteLine("Oops! You selected something other than a number of 1 or 2.\r\nPlease try again and make a menu selection of 1 or 2.\r\n");
                        Console.WriteLine(balanceSubMenu);
                        //Re-capture user response
                        balanceChoice = Console.ReadLine();

                        //re-convert to an integer
                        int.TryParse(balanceChoice, out balanceChoiceInt);
                    }


                    if (balanceChoiceInt == 1)
                    {
                        checking1.ViewBalance();
                    }

                    if (balanceChoiceInt == 2)
                    {
                        //savings1.DefaultSavingsBal();
                        savings1.ViewBalance();
                    }

                    break;

                //When user selects option three, display submenu so they can select checkings or savings
                case 3:


                    //Store submenu in a string
                    string depositSubMenu = ("BANK OF WESTEROS" + Environment.NewLine +
                                             "----------------------------------" + Environment.NewLine +
                                             "- [1] Deposit Funds into Checking Account" + Environment.NewLine +
                                             "- [2] Deposit Funds into Savings Account" + Environment.NewLine);
                    Console.WriteLine(depositSubMenu);     //Display submenu to console

                    string depositChoice = Console.ReadLine();

                    //Validate if user input anything
                    while (string.IsNullOrWhiteSpace(depositChoice))
                    {
                        Console.Clear();
                        //Tell user what went wrong
                        Console.WriteLine("Oops! You didn't select anything.\r\nPlease select a menu option of 1 or 2: ");

                        Console.WriteLine(depositChoice);

                        depositChoice = Console.ReadLine();
                    }

                    //Declare variable to hold the converted value of menu selection
                    int depositChoiceInt;

                    //Convert with TryParse
                    int.TryParse(depositChoice, out depositChoiceInt);


                    //Validate that user made a numerical choice between 1 and 5
                    while (depositChoiceInt < 1 || depositChoiceInt > 2)
                    {
                        Console.Clear();
                        //Tell user what went wrong
                        Console.WriteLine("Oops! You selected something other than a number of 1 or 2.\r\nPlease try again and make a menu selection of 1 or 2.\r\n");
                        Console.WriteLine(depositSubMenu);
                        //Re-capture user response
                        depositChoice = Console.ReadLine();

                        //re-convert to an integer
                        int.TryParse(depositChoice, out depositChoiceInt);
                    }

                    if (depositChoiceInt == 1)
                    {
                        Console.WriteLine("Please enter the amount of money you wish to deposit into your checking account:\r\n");
                        string depositAmount = Console.ReadLine();

                        //Validate if user input anything
                        while (string.IsNullOrWhiteSpace(depositChoice))
                        {
                            Console.Clear();
                            //Tell user what went wrong
                            Console.WriteLine("Oops! You didn't deposit anything.\r\nPlease enter the amount you wish to deposit: ");

                            depositAmount = Console.ReadLine();
                        }

                        //Declare variable to hold the converted value of deposit amount
                        double depositAmountDouble;

                        //Convert with TryParse
                        double.TryParse(depositAmount, out depositAmountDouble);

                        //Call methods for transactions
                        checking1.Deposit(depositAmountDouble);
                        checking1.PrintDepBalance();
                    }

                    if (depositChoiceInt == 2)
                    {
                        Console.WriteLine("Please enter the amount of money you wish to deposit into your savings account:\r\n");
                        string depositAmount = Console.ReadLine();

                        //Validate if user input anything
                        while (string.IsNullOrWhiteSpace(depositChoice))
                        {
                            Console.Clear();
                            //Tell user what went wrong
                            Console.WriteLine("Oops! You didn't deposit anything.\r\nPlease enter the amount you wish to deposit: ");

                            depositAmount = Console.ReadLine();
                        }

                        //Declare variable to hold the converted value of deposit amount
                        double depositAmountDouble;

                        //Convert with TryParse
                        double.TryParse(depositAmount, out depositAmountDouble);


                        //Call methods for transaction
                        savings1.Deposit(depositAmountDouble);
                        savings1.PrintDepBalance();
                    }



                    break;

                case 4:

                    //Store submenu in a string
                    string withdrawSubMenu = ("BANK OF WESTEROS" + Environment.NewLine +
                                              "----------------------------------" + Environment.NewLine +
                                              "- [1] Withdraw Funds from Checking Account" + Environment.NewLine +
                                              "- [2] Withdraw Funds from Savings Account" + Environment.NewLine);
                    Console.WriteLine(withdrawSubMenu);     //Display submenu to console

                    string withdrawChoice = Console.ReadLine();

                    //Validate if user input anything
                    while (string.IsNullOrWhiteSpace(withdrawChoice))
                    {
                        Console.Clear();
                        //Tell user what went wrong
                        Console.WriteLine("Oops! You didn't select anything.\r\nPlease select a menu option of 1 or 2: ");

                        Console.WriteLine(withdrawChoice);

                        depositChoice = Console.ReadLine();
                    }

                    //Declare variable to hold the converted value of menu selection
                    int withdrawChoiceInt;

                    //Convert with TryParse
                    int.TryParse(withdrawChoice, out withdrawChoiceInt);


                    //Validate that user made a numerical choice between 1 and 5
                    while (withdrawChoiceInt < 1 || withdrawChoiceInt > 2)
                    {
                        Console.Clear();
                        //Tell user what went wrong
                        Console.WriteLine("Oops! You selected something other than a number of 1 or 2.\r\nPlease try again and make a menu selection of 1 or 2.\r\n");
                        Console.WriteLine(withdrawSubMenu);
                        //Re-capture user response
                        withdrawChoice = Console.ReadLine();

                        //re-convert to an integer
                        int.TryParse(withdrawChoice, out withdrawChoiceInt);
                    }

                    if (withdrawChoiceInt == 1)
                    {
                        Console.WriteLine("Please enter the amount of money you wish to withdraw from your checking account:\r\n");
                        string withdrawAmount = Console.ReadLine();

                        //Validate if user input anything
                        while (string.IsNullOrWhiteSpace(withdrawAmount))
                        {
                            Console.Clear();
                            //Tell user what went wrong
                            Console.WriteLine("Oops! You didn't withdraw anything.\r\nPlease enter the amount you wish to withdraw: ");

                            withdrawAmount = Console.ReadLine();
                        }

                        //Declare variable to hold the converted value of deposit amount
                        double withdrawAmountDouble;

                        //Convert with TryParse
                        double.TryParse(withdrawAmount, out withdrawAmountDouble);

                        //Call on methods for transaction
                        checking1.Withdrawal(withdrawAmountDouble);
                        checking1.TransactionFee();
                        checking1.PrintWithdrawBalance();
                    }

                    if (withdrawChoiceInt == 2)
                    {
                        Console.WriteLine("Please enter the amount of money you wish to withdraw from your savings account:\r\n");
                        string withdrawAmount = Console.ReadLine();

                        //Validate if user input anything
                        while (string.IsNullOrWhiteSpace(withdrawAmount))
                        {
                            Console.Clear();
                            //Tell user what went wrong
                            Console.WriteLine("Oops! You didn't withdraw anything.\r\nPlease enter the amount you wish to withdraw: ");

                            withdrawAmount = Console.ReadLine();
                        }

                        //Declare variable to hold the converted value of deposit amount
                        double withdrawAmountDouble;

                        //Convert with TryParse
                        double.TryParse(withdrawAmount, out withdrawAmountDouble);

                        //Call methods for the transaction
                        savings1.Withdrawal(withdrawAmountDouble);
                        savings1.TransactionFee();
                        savings1.PrintWithdrawBalance();
                    }

                    break;

                case 5:

                    Console.Clear();
                    Console.WriteLine("Thank you for banking with us! Goodbye!\r\n\r\n");     //Goodbye message for user
                    return;


                default:
                    break;
                }
            } while (true);
        }
Exemplo n.º 11
0
        static void Main(string[] args)
        {
            //public static void getMenu()


            Client          newClient   = new Client("Tyler", "Graves", "July 26 1990", "1426 Imaginary Ave", "135-79-2468");
            CheckingAccount newChecking = new CheckingAccount();
            SavingsAccount  newSaving   = new SavingsAccount(150);



            Console.WriteLine("Hello, welcome to the big bank of code!");
            Console.WriteLine();
            Console.WriteLine("Please select a number based on the following options");

            string menuFunctions = "1,2,3,4,5";

            do
            {
                Console.WriteLine("1. View client information \n 2. View account balance \n 3. Deposit funds \n 4. Withdraw funds \n  5. Exit");
                string menuSelect = Console.ReadLine();
                switch (menuSelect.ToLower())
                {
                case "1":
                    newClient.showInfo();
                    Console.WriteLine();
                    break;

                case "2":
                    Console.WriteLine("Would you like an account balance for your Checking or Savings?");
                    string accountSelection = Console.ReadLine();
                    if (accountSelection == "Checking")
                    {
                        newChecking.DisplayAccountBalance();
                        Console.WriteLine();
                    }
                    else if (accountSelection == "Savings")
                    {
                        newSaving.DisplayAccountBalance();
                        Console.WriteLine();
                    }

                    break;

                case "3":
                    Console.WriteLine("Would you like to deposit into your checking or savings account today?");
                    string depositSelection = Console.ReadLine();
                    if (depositSelection == "Checking")
                    {
                        newChecking.DisplayDepositAmount();
                        Console.WriteLine();
                    }
                    else if (depositSelection == "Savings")
                    {
                        newSaving.DisplayDepositAmount();
                        Console.WriteLine();
                    }
                    else
                    {
                        Console.WriteLine("Please select Checking or Savings");
                        string response = Console.ReadLine();
                    }
                    break;

                case "4":
                    Console.WriteLine("Would you like to withdraw from your Checking or Savings account today?");
                    string withdrawSelection = Console.ReadLine();
                    if (withdrawSelection == "Checking")
                    {
                        newChecking.DisplayWithdrawAmount();
                        Console.WriteLine();
                    }
                    else if (withdrawSelection == "Savings")
                    {
                        newSaving.DisplayWithdrawAmount();
                        Console.WriteLine();
                    }
                    else
                    {
                        Console.WriteLine("Please select Checking or Savings");
                        string response = Console.ReadLine();
                    }
                    break;

                case "5":
                    Console.WriteLine();
                    break;
                }
            } while (menuFunctions != "5");
        }
Exemplo n.º 12
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();
        }
Exemplo n.º 13
0
        static void Main(string[] args)
        {
            CheckingAccount checkBalance = new CheckingAccount(535.78, 24681013, "Checking", 5);
            ///need input inside the method, but for some reason it doesn't matter what number is there because it does not effect my program. not sure why.
            ///ex. 5 for checking account and 23 for savings (random numbers)
            SavingsAccount saveBalance = new SavingsAccount(898.15, 35791113, "Savings", 23);
            Client         userClient  = new Client();

            string transInput = "";//transInput is the users input if they have another transaction or not (YES/NO)

            do
            {
                Console.WriteLine("1. View Client Information");
                Console.WriteLine("2. View Account Balance");
                Console.WriteLine("3. Deposit Funds");
                Console.WriteLine("4. Withdraw Funds");
                Console.WriteLine("5. Exit");
                Console.WriteLine("Please enter a number for the action you would like to perfom.");

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

                string accountInput = " ";//accountInput is when the user types "C" or "S" for which account they would like to perform there action in
                switch (userInput)
                {
                case 1:
                    userClient.ClientInfo();
                    Console.WriteLine(userClient.Name);
                    Console.WriteLine(userClient.Address);
                    Console.WriteLine(userClient.TelephoneNumber);
                    Console.WriteLine("Do you have another transaction? YES/NO");
                    transInput = Console.ReadLine().ToUpper();
                    break;

                case 2:
                    Console.WriteLine("Would you like the balance of your Checking Account or Savings Account? Enter C for Checking or S for Savings.");
                    accountInput = Console.ReadLine().ToUpper();
                    if (accountInput == "C")
                    {
                        checkBalance.AccountInfo();
                        Console.WriteLine(checkBalance.Balance);
                    }
                    else if (accountInput == "S")
                    {
                        saveBalance.SaveAccountInfo();
                        Console.WriteLine(saveBalance.Balance);
                    }
                    Console.WriteLine("Do you have another transaction? YES/NO");
                    transInput = Console.ReadLine().ToUpper();
                    break;

                case 3:
                    Console.WriteLine("Which account would you like to deposit funds into? Enter C for Checking or S for Savings.");
                    accountInput = Console.ReadLine().ToUpper();
                    if (accountInput == "C")
                    {
                        Console.WriteLine("Please enter the amount you would like to deposit.");
                        checkBalance.Deposit();
                        Console.WriteLine("Your new balance is " + checkBalance.Balance);
                    }
                    else if (accountInput == "S")
                    {
                        Console.WriteLine("Please enter the amount you would like to deposit.");
                        saveBalance.Deposit();
                        Console.WriteLine("Your new balance is " + saveBalance.Balance);
                    }
                    Console.WriteLine("Do you have another transaction? YES/NO");
                    transInput = Console.ReadLine().ToUpper();
                    break;

                case 4:
                    Console.WriteLine("Which account would you like to withdraw funds from? Enter C for Checking or S for Savings.");
                    accountInput = Console.ReadLine().ToUpper();
                    if (accountInput == "C")
                    {
                        Console.WriteLine("Please enter the amount you would like to withdraw.");
                        checkBalance.Withdraw();
                        Console.WriteLine("Your new balance is " + checkBalance.Balance);
                    }
                    else if (accountInput == "S")
                    {
                        Console.WriteLine("Please enter the amount you would like to withdraw.");
                        saveBalance.Withdraw();
                        Console.WriteLine("Your new balance is " + saveBalance.Balance);
                    }
                    Console.WriteLine("Do you have another transaction? YES/NO");
                    transInput = Console.ReadLine().ToUpper();
                    break;

                case 5:
                    Console.WriteLine("Goodbye!");
                    break;
                }
            }while (transInput == "YES");
        }
Exemplo n.º 14
0
        static void Main(string[] args)
        {
            ClientInfo      userInfo     = new ClientInfo("Ben", "Klein", 1560, "Saint Charles Ave", "Lakewood", "OH", 44107);
            CheckingAccount userChecking = new CheckingAccount(1234, 10000.99);
            SavingsAccount  userSavings  = new SavingsAccount(5678, 25000.89);

            int  userChoice;
            char userChoice2;

            Console.WriteLine("Welcome to 99th Federal Bank of WCCI");
            Console.WriteLine("");

            do
            {
                Console.WriteLine("What can we help you with today?");
                Console.WriteLine("View Client Information, type 1");
                Console.WriteLine("View Account Balance, type 2");
                Console.WriteLine("Deposit Funds, type 3");
                Console.WriteLine("Withdraw Funds, type 4");
                Console.WriteLine("Exit, type 5");

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

                switch (userChoice)
                {
                case 1:
                    userInfo.ViewInfo();
                    break;

                case 2:
                    Console.WriteLine("Which account balance do you wish to check?");
                    Console.WriteLine("Type C for checking");
                    Console.WriteLine("Type S for savings");

                    userChoice2 = char.Parse(Console.ReadLine().ToUpper());

                    if (userChoice2 == 'C')
                    {
                        userChecking.ViewBalance();        //does it know which subclass method to call?
                        break;
                    }
                    else if (userChoice2 == 'S')
                    {
                        userSavings.ViewBalance();
                        break;
                    }
                    else
                    {
                        break;
                    }

                case 3:
                    Console.WriteLine("Which account do you wish to deposit funds to?");
                    Console.WriteLine("Type C for checking");
                    Console.WriteLine("Type S for savings");

                    userChoice2 = char.Parse(Console.ReadLine().ToUpper());

                    if (userChoice2 == 'C')
                    {
                        userChecking.DepositFunds();
                        break;
                    }
                    else if (userChoice2 == 'S')
                    {
                        userSavings.DepositFunds();
                        break;
                    }
                    else
                    {
                        break;
                    }

                case 4:
                    Console.WriteLine("Which account do you wish to withdraw funds from?");
                    Console.WriteLine("Type C for checking");
                    Console.WriteLine("Type S for savings");

                    userChoice2 = char.Parse(Console.ReadLine().ToUpper());

                    if (userChoice2 == 'C')
                    {
                        userChecking.WithdrawFunds();
                        break;
                    }
                    else if (userChoice2 == 'S')
                    {
                        userSavings.WithdrawFunds();
                        break;
                    }
                    else
                    {
                        break;
                    }

                case 5:
                    Console.WriteLine("Goodbye.");
                    break;
                }
            } while (userChoice <= 4);
        }
Exemplo n.º 15
0
        static void Main(string[] args)
        {
            Client          client = new Client("Gerald Garner", "100100100", "100100101");   //instantiate a Client object
            CheckingAccount clientCheckingAccount = new CheckingAccount("100100100", 10000);  //instantiate a CheckingAccount object
            SavingsAccount  clientSavingsAccount  = new SavingsAccount("100100101", 1000000); //instantiate a SavingsAccount object

            int     userInput;
            string  accountChoice;
            decimal amount;

            //print menu
            Console.WriteLine("Welcome to the Bank\n\nMenu:\n\n1. View Client Information\n2. View Account Balance\n3. Deposit Funds\n4. Withdraw Funds\n5. Exit");

            //allow user to continue making selections until they enter "5" (exit)
            do
            {
                Console.WriteLine("\nEnter a selection 1-5 from the menu above");
                Int32.TryParse(Console.ReadLine(), out userInput);

                switch (userInput)
                {
                case 1:     //client info
                    Console.WriteLine("\n" + client.ListClientInformation());
                    break;

                case 2:     //account balance
                    accountChoice = GetAccountChoice();
                    if (accountChoice == "a")
                    {
                        clientCheckingAccount.DisplayAccountBalance();
                    }
                    else
                    {
                        clientSavingsAccount.DisplayAccountBalance();
                    }
                    break;

                case 3:                       //deposit funds
                    accountChoice = GetAccountChoice();
                    if (accountChoice == "a") //checking
                    {
                        amount = GetAmount();
                        clientCheckingAccount.DepositMoney(amount);
                    }
                    else     //savings
                    {
                        amount = GetAmount();
                        clientSavingsAccount.DepositMoney(amount);
                    }

                    break;

                case 4:                       //withdraw funds
                    accountChoice = GetAccountChoice();
                    if (accountChoice == "a") //checking
                    {
                        amount = GetAmount();
                        clientCheckingAccount.WithdrawMoney(amount);
                    }
                    else     //savings
                    {
                        amount = GetAmount();
                        clientSavingsAccount.WithdrawMoney(amount);
                    }
                    break;

                case 5:     //exit
                    Console.WriteLine("Have a nice day!");
                    break;

                default:     //if user does not enter 1-5, they will be reminded to do so and loop will run again
                    Console.WriteLine("You must select a number 1-5");
                    break;
                }
            }while (userInput != 5);
        }
Exemplo n.º 16
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);
            }
        }
Exemplo n.º 17
0
        static void Main(string[] args)
        {
            string answer;

            Console.WriteLine("Welcome to your bank!");
            Client          cl           = new Client("Ferris", "Bueller", "1234 Chicago, Illinois", "555-0095");
            SavingsAccount  sa           = new SavingsAccount(1000.75M);
            CheckingAccount ca           = new CheckingAccount(1000.25M);
            decimal         BalanceValue = 100;

            do
            {
                Console.WriteLine("Please enter your selection!");
                Console.WriteLine("1. View Client Information");
                Console.WriteLine("2. View Account Balance");
                Console.WriteLine("3. Deposit Funds");
                Console.WriteLine("4. Withdraw Funds");
                Console.WriteLine("5. Exit");

                answer = (Console.ReadLine());



                if (answer == "1")
                {
                    cl.GetClientInfo();
                    Console.WriteLine("Press any key to continue");
                    answer = (Console.ReadLine());
                }
                if (answer == "2")
                {
                    Console.WriteLine("a. Checking Account\nb. Savings Account");
                    string selection = Console.ReadLine().ToLower();
                    if (selection == "a")
                    {
                        Console.WriteLine("Checking account balance is {0:C}", ca.Balance);

                        answer = (Console.ReadLine());
                    }
                    if (selection == "b")
                    {
                        Console.WriteLine("Savings account balance is {0:C}", sa.Balance);
                        answer = (Console.ReadLine());
                    }
                    else
                    {
                        continue;
                    }
                }
                if (answer == "3")
                {
                    Console.WriteLine("a. Deposit Into Checking Account\nb. Deposit Into Savings Account");
                    string selection = Console.ReadLine().ToLower();
                    if (selection == "a")
                    {
                        Console.WriteLine("How much would you like to deposit?");
                        decimal credit = decimal.Parse(Console.ReadLine());
                        ca.Balance = ca.Deposit(credit);
                        Console.WriteLine("Your new balance is " + ca.Balance);
                    }
                    if (selection == "b")
                    {
                        Console.WriteLine("How much would you like to deposit?");
                        decimal credit = decimal.Parse(Console.ReadLine());
                        sa.Balance = sa.Deposit(credit);
                        Console.WriteLine("Your new balance is " + sa.Balance);
                    }
                    else
                    {
                        continue;
                    }
                }
                if (answer == "4")
                {
                    Console.WriteLine("a. Withdraw From Checking Account\nb. Withdraw From Savings Account");
                    string selection = Console.ReadLine().ToLower();
                    if (selection == "a")
                    {
                        Console.WriteLine("How much would you like to withdraw?");
                        decimal debit = decimal.Parse(Console.ReadLine());
                        if (debit > ca.Balance)
                        {
                            Console.WriteLine("Insufficient Funds, enter a different amount");
                            debit = decimal.Parse(Console.ReadLine());
                        }
                        ca.Balance = ca.Withdraw(debit);
                        Console.WriteLine("Your new balance is " + ca.Balance);
                    }
                    if (selection == "b")
                    {
                        Console.WriteLine("How much would you like to withdraw?");
                        decimal debit = decimal.Parse(Console.ReadLine());
                        if (debit > sa.Balance - BalanceValue)
                        {
                            Console.WriteLine("Insufficient Funds, enter a different amount");
                            debit = decimal.Parse(Console.ReadLine());
                        }
                        sa.Balance = sa.Withdraw(debit);
                        Console.WriteLine("Your new balance is " + sa.Balance);
                    }
                    else
                    {
                        continue;
                    }
                }
            } while (answer != "5");
        }
Exemplo n.º 18
0
        static void Main(string[] args)
        {
            int    bankInput;
            string depositInput;
            string balanceInput;
            string withdrawInput;

            SavingsAccount  newSavings  = new SavingsAccount(10000, 98765);
            CheckingAccount newChecking = new CheckingAccount(5000.00, 12345);
            Client          newClient   = new Client("Jane", "Doe");


            Console.WriteLine("Welcome to the Bank");
            Console.WriteLine();

            do
            {
                Console.WriteLine("What would you like to do?");

                Console.WriteLine("1. View Client Information");
                Console.WriteLine("2. View Account Balance");
                Console.WriteLine("3. Deposit Funds");
                Console.WriteLine("4. Withdraw Funds");
                Console.WriteLine("5. Exit");
                Console.WriteLine();

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



                switch (bankInput)
                {
                case 1:
                    newClient.Info();
                    break;

                case 2:
                    Console.WriteLine("Which account would you like to check the balance for?");
                    Console.WriteLine("Press A for checking account");
                    Console.WriteLine("Press B for savings account");
                    balanceInput = Console.ReadLine();
                    break;


                case 3:
                    Console.WriteLine("Which account would you like to add money to?");
                    Console.WriteLine("Press A for checking account");
                    Console.WriteLine("Press B for savings account");
                    depositInput = Console.ReadLine();
                    break;


                case 4:
                    Console.Write("Which account would you like to remove money from?");
                    Console.WriteLine("Press A for checking account");
                    Console.WriteLine("Press B for savings account");
                    withdrawInput = Console.ReadLine();
                    break;
                }
            } while (bankInput != 5);
            Console.WriteLine("Thank you for using Bank.");
        }
Exemplo n.º 19
0
        static void Main(string[] args)
        {
            //instantiating our client and accounts.
            Client          oswaldCobblepot = new Client();
            CheckingAccount oswaldChecking  = new CheckingAccount();
            SavingsAccount  oswaldSavings   = new SavingsAccount();

            string firstChoice;
            string secondChoice;
            double deposit;
            double withdraw;

            do
            {
                // Welcome user and give them the menu to make their choices.
                Console.WriteLine("Welcome to Gotham National Bank.");
                Console.WriteLine("Please make a selection from the following menu.\n");
                Console.WriteLine("1. View Client Information\n2. View Account Balance\n3. Deposit Funds\n4. Withdraw Funds\n5. Exit\nPlease enter the number of your choice");
                firstChoice = Console.ReadLine();
                Console.Clear();

                //prints users info
                if (firstChoice == "1")
                {
                    oswaldCobblepot.Info();
                    Console.WriteLine("Press enter when done.");
                    Console.ReadLine();
                    Console.Clear();
                }

                //Shows balances of users accounts
                if (firstChoice == "2")
                {
                    do
                    {
                        Console.WriteLine("1. Checking Account Balance\n2. Savings Account Balance\n3. Back\n4. Exit");
                        secondChoice = Console.ReadLine();
                        Console.Clear();

                        if (secondChoice == "1")
                        {
                            Console.WriteLine("Your checking account balance is :");
                            oswaldChecking.GetBalance();
                        }

                        if (secondChoice == "2")
                        {
                            Console.WriteLine("Your savings account balance is :");
                            oswaldSavings.GetBalance();
                        }

                        if (secondChoice == "3")
                        {
                            break;
                        }

                        if (secondChoice == "4")
                        {
                            firstChoice = "5";
                            break;
                        }
                    } while (secondChoice != "1" || secondChoice != "2" || secondChoice != "3" || secondChoice != "4");
                }

                //allows user to deposit funds in their account.
                if (firstChoice == "3")
                {
                    do
                    {
                        Console.WriteLine("In which account would you like to make a deposit?\n1. Checking Account\n2. Savings Account\n3. Back\n4. Exit");
                        secondChoice = Console.ReadLine();
                        Console.Clear();

                        if (secondChoice == "1")
                        {
                            Console.WriteLine("How much would you like to deposit?");
                            deposit = double.Parse(Console.ReadLine());
                            oswaldChecking.Balance = oswaldChecking.Deposit(deposit);
                            Console.WriteLine("Your new balance is ");
                            oswaldChecking.GetBalance();
                            Console.WriteLine("Press enter to continue");
                            Console.ReadLine();
                            Console.Clear();
                        }

                        if (secondChoice == "2")
                        {
                            Console.WriteLine("How much would you like to deposit?");
                            deposit = double.Parse(Console.ReadLine());
                            oswaldSavings.Balance = oswaldSavings.Deposit(deposit);
                            Console.WriteLine("Your new balance is ");
                            oswaldSavings.GetBalance();
                            Console.WriteLine("Press enter to continue");
                            Console.ReadLine();
                            Console.Clear();
                        }

                        if (secondChoice == "3")
                        {
                            break;
                        }

                        if (secondChoice == "4")
                        {
                            firstChoice = "5";
                            break;
                        }
                    } while (secondChoice != "1" || secondChoice != "2" || secondChoice != "3" || secondChoice != "4");
                }

                //allows user to withdraw money from accounts
                if (firstChoice == "4")
                {
                    do
                    {
                        Console.WriteLine("In which account would you like to make a withdraw?\n1. Checking Account\n2. Savings Account\n3. Back\n4. Exit");
                        secondChoice = Console.ReadLine();
                        Console.Clear();

                        if (secondChoice == "1")
                        {
                            Console.WriteLine("How much would you like to withdraw?");
                            withdraw = double.Parse(Console.ReadLine());
                            oswaldChecking.Balance = oswaldChecking.Withdraw(withdraw);
                            Console.WriteLine("Your new balance is ");
                            oswaldChecking.GetBalance();
                            Console.WriteLine("Press enter to continue");
                            Console.ReadLine();
                            Console.Clear();
                        }

                        if (secondChoice == "2")
                        {
                            Console.WriteLine("How much would you like to withdraw?");
                            withdraw = double.Parse(Console.ReadLine());

                            //Checking to make sure savings account does not go below zero.
                            if (withdraw > oswaldSavings.Balance)
                            {
                                Console.WriteLine("Can not continue this transaction.\nInsuffient Funds.");
                                Console.WriteLine("Press enter to continue.");
                                Console.ReadLine();
                                Console.Clear();
                                break;
                            }
                            oswaldSavings.Balance = oswaldSavings.Withdraw(withdraw);
                            Console.WriteLine("Your new balance is ");
                            oswaldSavings.GetBalance();
                            Console.WriteLine("Press enter to continue");
                            Console.ReadLine();
                            Console.Clear();
                        }

                        if (secondChoice == "3")
                        {
                            break;
                        }

                        if (secondChoice == "4")
                        {
                            firstChoice = "5";
                            break;
                        }
                    } while (secondChoice != "1" || secondChoice != "2" || secondChoice != "3" || secondChoice != "4");
                }
            } while (firstChoice != "5");

            Console.WriteLine("Have a great day!");
        }
Exemplo n.º 20
0
        static void Main(string[] args)
        {
            bool HasNumber(string input)//elegxos na mhn dwthoun arithmitika stoixeia
            {
                return(input.Where(x => Char.IsDigit(x)).Any());
            }

            Console.WriteLine("Welcome to our Bank.\nPlease enter first name:\n");
            string firstName = Console.ReadLine();

            while (HasNumber(firstName))
            {
                Console.WriteLine("Please enter first name without numbers:\n");
                firstName = Console.ReadLine();
            }

            Console.WriteLine("Please enter last name:\n");
            string lastName = Console.ReadLine();

            while (HasNumber(lastName))
            {
                Console.WriteLine("Please enter last name without numbers:\n");
                lastName = Console.ReadLine();
            }

            Regex ibanRegex = new Regex("[0-9]");

            Console.WriteLine("Please enter IBAN:\n");
            string iban = Console.ReadLine();

            while (!(ibanRegex.IsMatch(iban) && iban.Length == 16)) //elegxoume an to iban exei mono arithmous kai einai 16pshfio
            {
                Console.WriteLine("Please enter a 16 numbers - IBAN without chars:\n");
                iban = Console.ReadLine();
            }

            Customer customer1 = new Customer(firstName, lastName, iban);

            long amount;


            Console.WriteLine("Please choose:\n 1 for Credit Account.\n 2 for Savings Account.\n 3 for Lottery Account.\n 4 Quit. \n");
            string decision = Console.ReadLine();

            while (decision != "4")
            {
                switch (decision)
                {
                case "1":
                    CreditAccount creditAccount1 = new CreditAccount(firstName, lastName, iban);
                    Console.WriteLine("Please choose:\n 1 for Charge.\n 2 for Deposit.\n 3 for Add Payment.\n 4 Quit. \n");
                    decision = Console.ReadLine();
                    while (decision != "4")
                    {
                        switch (decision)
                        {
                        case "1":
                            Console.WriteLine("Write your amount:\n");
                            amount = long.Parse(Console.ReadLine());
                            creditAccount1.charge(amount);
                            break;

                        case "2":
                            Console.WriteLine("Write your amount:\n");
                            amount = long.Parse(Console.ReadLine());
                            creditAccount1.deposit(amount);
                            break;

                        case "3":
                            creditAccount1.addPayment();
                            break;

                        default:
                            Console.WriteLine("Choose right number");
                            break;
                        }

                        Console.WriteLine("Please choose:\n 1 for Charge.\n 2 for Deposit.\n 3 for Add Payment.\n 4 Quit.\n");
                        decision = Console.ReadLine();
                    }


                    break;

                case "2":
                    SavingsAccount savingsAccount1 = new SavingsAccount(firstName, lastName, iban);
                    Console.WriteLine("Please choose:\n 1 for Withdraw.\n 2 for Deposit.\n 3 for Add Interest.\n 4 Quit.\n");
                    decision = Console.ReadLine();
                    while (decision != "4")
                    {
                        switch (decision)
                        {
                        case "1":
                            Console.WriteLine("Write your amount:\n");
                            amount = long.Parse(Console.ReadLine());
                            savingsAccount1.withdraw(amount);
                            break;

                        case "2":
                            Console.WriteLine("Write your amount:\n");
                            amount = long.Parse(Console.ReadLine());
                            savingsAccount1.deposit(amount);
                            break;

                        case "3":
                            savingsAccount1.addInterest();
                            break;

                        default:
                            Console.WriteLine("Choose right number");
                            break;
                        }

                        Console.WriteLine("Please choose:\n 1 for Withdraw.\n 2 for Deposit.\n 3 for Add Interest.\n 4 Quit.\n");
                        decision = Console.ReadLine();
                    }

                    break;

                case "3":
                    LotteryAccount lotteryAccount1 = new LotteryAccount(firstName, lastName, iban);
                    Console.WriteLine("Please choose:\n 1 for Withdraw.\n 2 for Deposit.\n 3 Quit.\n");
                    decision = Console.ReadLine();
                    while (decision != "3")
                    {
                        switch (decision)
                        {
                        case "1":
                            Console.WriteLine("Write your amount:\n");
                            amount = long.Parse(Console.ReadLine());
                            lotteryAccount1.withdraw(amount);
                            lotteryAccount1.winPercentage();         //sygkrinei 2 tyxaious arithmous se kathe synallagi me pithanotita 1% na dwsei 50 eyrw
                            break;

                        case "2":
                            Console.WriteLine("Write your amount:\n");
                            amount = long.Parse(Console.ReadLine());
                            lotteryAccount1.deposit(amount);
                            lotteryAccount1.winPercentage();
                            break;

                        default:
                            Console.WriteLine("Choose right number.\n");
                            break;
                        }

                        Console.WriteLine("Please choose:\n 1 for Withdraw.\n 2 for Deposit.\n 3 Quit.\n");
                        decision = Console.ReadLine();
                    }

                    break;

                default:
                    Console.WriteLine("Choose right number.\n");
                    break;
                }

                Console.WriteLine("Please choose:\n 1 for Credit Account.\n 2 for Savings Account.\n 3 for Lottery Account.\n 4 Quit. \n");
                decision = Console.ReadLine();
            }
        }
Exemplo n.º 21
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to Community Bank of Northern Alaska! \n");
            Console.WriteLine("Our menu of options follows: ");

            Console.WriteLine("1. View Client Information");
            Console.WriteLine("2. View Account Balance");
            Console.WriteLine("3. Deposit Funds");
            Console.WriteLine("4. Withdraw Funds");
            Console.WriteLine("5. Exit \n");

            Console.WriteLine("Enter the number of menu item you wish to view: \n");

            int menuSelection;

            do
            {
                menuSelection = int.Parse(Console.ReadLine());
                if (menuSelection == 1)
                {
                    Console.WriteLine("\nFollowing is your Client Information: \n");
                    //create instance of client
                    Client clientInfo = new Client("Sally Smith", "32789 Duluthe Street, Wayupyonder, Alaska", "(990) 341-2367");
                    clientInfo.ShowClientInfo();
                    Console.WriteLine(clientInfo.ShowClientInfo());
                    Console.WriteLine("");

                    Console.WriteLine("Following is your Account information: \n");
                    //create another instance of client
                    Client clientAccountInfo = new Client("234059 0002345", "721134 00000381");
                    clientAccountInfo.ShowAccountInfo();
                    Console.WriteLine(clientAccountInfo.ShowAccountInfo());

                    Console.WriteLine("\nWhat do you want to do next?\n");

                    Console.WriteLine("1. View Client Information");
                    Console.WriteLine("2. View Account Balance");
                    Console.WriteLine("3. Deposit Funds");
                    Console.WriteLine("4. Withdraw Funds");
                    Console.WriteLine("5. Exit \n");
                }
                else if (menuSelection == 2)
                {
                    string balanceSelect;
                    Console.WriteLine("\nWhich Account Balance do you want to view? \n");
                    Console.WriteLine("a. Checking Account");
                    Console.WriteLine("b. Savings Account");
                    Console.WriteLine("\nEnter letter here: ");
                    balanceSelect = Console.ReadLine();
                    if (balanceSelect == "a")
                    {
                        CheckingAccount checkingBalance = new CheckingAccount();
                        checkingBalance.GetCheckingBalance();
                        Console.WriteLine("\nChecking Account Balance: $" + checkingBalance.ShowInitialCheckingBalance());
                        Console.WriteLine("");
                    }
                    if (balanceSelect == "b")
                    {
                        SavingsAccount savingsBalance = new SavingsAccount();
                        savingsBalance.GetSavingsBalance();
                        Console.WriteLine("\nSavings Account Balance: $" + savingsBalance.ShowInitialSavingsBalance());
                        Console.WriteLine("");
                    }

                    Console.WriteLine("What do you want to do next?\n");

                    Console.WriteLine("1. View Client Information");
                    Console.WriteLine("2. View Account Balance");
                    Console.WriteLine("3. Deposit Funds");
                    Console.WriteLine("4. Withdraw Funds");
                    Console.WriteLine("5. Exit \n");
                }
                else if (menuSelection == 3)
                {
                    string depositSelect;
                    Console.WriteLine("\nTo which Account do you want to deposit? \n");
                    Console.WriteLine("a. Checking Account");
                    Console.WriteLine("b. Savings Account");
                    Console.WriteLine("\nPlease enter letter here: ");
                    depositSelect = Console.ReadLine();
                    if (depositSelect == "a")
                    {
                        Console.WriteLine("\nEnter your Checking Account deposit amount: ");
                        double          checkingDeposit        = double.Parse(Console.ReadLine());
                        CheckingAccount depositCheckingAccount = new CheckingAccount(checkingDeposit);
                        depositCheckingAccount.DepositIntoChecking();
                        Console.WriteLine("\nThank you for your deposit! Your new Checking Account Balance is: $" + depositCheckingAccount.DepositIntoChecking());
                        Console.WriteLine("");
                    }
                    if (depositSelect == "b")
                    {
                        Console.WriteLine("\nEnter your Savings Account deposit amount: ");
                        double         savingsDeposit        = double.Parse(Console.ReadLine());
                        SavingsAccount depositSavingsAccount = new SavingsAccount(savingsDeposit);
                        depositSavingsAccount.DepositIntoSavings();
                        Console.WriteLine("\nThank you for your deposit! Your new Savings Account Balance is: $" + depositSavingsAccount.DepositIntoSavings());
                        Console.WriteLine("");
                    }

                    Console.WriteLine("What do you want to do next?\n");

                    Console.WriteLine("1. View Client Information");
                    Console.WriteLine("2. View Account Balance");
                    Console.WriteLine("3. Deposit Funds");
                    Console.WriteLine("4. Withdraw Funds");
                    Console.WriteLine("5. Exit \n");
                }
                else if (menuSelection == 4)
                {
                    string withdrawSelect;
                    Console.WriteLine("\nFrom which Account do you want to withdraw? \n");
                    Console.WriteLine("a. Checking Account");
                    Console.WriteLine("b. Savings Account\n");
                    Console.WriteLine("\nPlease enter letter here: ");
                    withdrawSelect = Console.ReadLine();
                    if (withdrawSelect == "a")
                    {
                        Console.WriteLine("\nEnter your Checking Account withdraw amount: ");
                        double          checkingWithdraw        = double.Parse(Console.ReadLine());
                        CheckingAccount withdrawCheckingAccount = new CheckingAccount(checkingWithdraw);
                        withdrawCheckingAccount.WithdrawFromChecking();
                        Console.WriteLine("\nThank you for your withdrawal. Your new Checking Account Balance is: $" + withdrawCheckingAccount.WithdrawFromChecking());
                        Console.WriteLine("");
                    }
                    if (withdrawSelect == "b")
                    {
                        Console.WriteLine("\nEnter your Savings Account withdraw amount: ");
                        double         savingsWithdraw        = double.Parse(Console.ReadLine());
                        SavingsAccount withdrawSavingsAccount = new SavingsAccount(savingsWithdraw);
                        withdrawSavingsAccount.WithdrawFromSavings();
                        Console.WriteLine("\nThank you for your withdrawal. Your new Savings Account Balance is: $" + withdrawSavingsAccount.WithdrawFromSavings());
                        Console.WriteLine("");
                    }

                    Console.WriteLine("What do you want to do next?\n");

                    Console.WriteLine("1. View Client Information");
                    Console.WriteLine("2. View Account Balance");
                    Console.WriteLine("3. Deposit Funds");
                    Console.WriteLine("4. Withdraw Funds");
                    Console.WriteLine("5. Exit \n");
                }
                else
                {
                    return;
                }
            } while (true);
        }
Exemplo n.º 22
0
        static void Main(string[] args)
        {
            //Object substantiating

            Client          Daniel       = new Client("Daniel", "Platinum", "867-5309");
            SavingsAccount  savAccount   = new SavingsAccount(500.0d, 123456);
            CheckingAccount checkAccount = new CheckingAccount(1000.0d, 654321);


            //User input setup
            string choiceOne   = "1. View Client Information";
            string choiceTwo   = "2. View Account Balance";
            string choiceThree = "3. Deposit Funds ";
            string choiceFour  = "4. Withdraw Funds";
            string choiceFive  = "5. Exit";

            Console.WriteLine("Welcome to your personal bank account manager!");
            Console.WriteLine("Please choose from the choices below by picking a number:");

            //Start for goto loop to return back here
Start:
            Console.WriteLine(choiceOne);
            Console.WriteLine(choiceTwo);
            Console.WriteLine(choiceThree);
            Console.WriteLine(choiceFour);
            Console.WriteLine(choiceFive);
            string userChoice = Console.ReadLine();

            //User input result/action

            //Client info
            while (userChoice == "1" || userChoice == "1.")
            {
                Daniel.DisplayInformation();
                Console.WriteLine("Would you like to do something else? (Yes/No)");
                if (Console.ReadLine().ToUpper() == "YES")
                {
                    goto Start;
                }
                else
                {
                    Console.WriteLine("Thank you for banking with WCCI Bank!");
                    Environment.Exit(0);
                }
            }

            //Account Balance
            while (userChoice == "2" || userChoice == "2.")
            {
                Console.WriteLine("Which account balance would you like to view?");
                Console.WriteLine("1. Checking Account");
                Console.WriteLine("2. Savings Account");
                string subChoice = Console.ReadLine();
                if (subChoice == "1" || subChoice == "1.")
                {
                    Console.WriteLine("Your checking account contains: " + checkAccount.checkingAccountBalance + ".");
                    Console.WriteLine("Would you like to do something else? (Yes/No)");
                    if (Console.ReadLine().ToUpper() == "YES")
                    {
                        goto Start;
                    }
                    else
                    {
                        Console.WriteLine("Thank you for banking with WCCI Bank!");
                        Environment.Exit(0);
                    }
                }
                else if (subChoice == "2" || subChoice == "2.")
                {
                    Console.WriteLine("Your savings account contains: " + savAccount.savingsAccountBalance + ".");
                    Console.WriteLine("Would you like to do something else? (Yes/No)");
                    if (Console.ReadLine().ToUpper() == "YES")
                    {
                        goto Start;
                    }
                    else
                    {
                        Console.WriteLine("Thank you for banking with WCCI Bank!");
                        Environment.Exit(0);
                    }
                }
            }

            //Deposit money
            while (userChoice == "3" || userChoice == "3.")
            {
                Console.WriteLine("Deposit to which account?");
                Console.WriteLine("1. Checking Account");
                Console.WriteLine("2. Savings Account");
                string subChoice = Console.ReadLine();
                if (subChoice == "1" || subChoice == "1.")
                {
                    checkAccount.AddBalance();
                    Console.WriteLine("Would you like to do something else? (Yes/No)");
                    if (Console.ReadLine().ToUpper() == "YES")
                    {
                        goto Start;
                    }
                    else
                    {
                        Console.WriteLine("Thank you for banking with WCCI Bank!");
                        Environment.Exit(0);
                    }
                }
                else if (subChoice == "2" || subChoice == "2.")
                {
                    savAccount.AddBalance();
                    Console.WriteLine("Would you like to do something else? (Yes/No)");
                    if (Console.ReadLine().ToUpper() == "YES")
                    {
                        goto Start;
                    }
                    else
                    {
                        Console.WriteLine("Thank you for banking with WCCI Bank!");
                        Environment.Exit(0);
                    }
                }
                else if (subChoice.ToUpper() == "EXIT")
                {
                    Console.WriteLine("Thank you for banking with WCCI Bank!");
                    Environment.Exit(0);
                }
            }

            //Withdraw money
            while (userChoice == "4" || userChoice == "4.")
            {
                Console.WriteLine("Withdraw from which account?");
                Console.WriteLine("1. Checking Account");
                Console.WriteLine("2. Savings Account");
                string subChoice = Console.ReadLine();
                while (subChoice == "1" || subChoice == "1.")
                {
                    checkAccount.DeductBalance();
                    Console.WriteLine("Would you like to do something else? (Yes/No)");
                    if (Console.ReadLine().ToUpper() == "YES")
                    {
                        goto Start;
                    }
                    else
                    {
                        Console.WriteLine("Thank you for banking with WCCI Bank!");
                        Environment.Exit(0);
                    }
                }
                while (subChoice == "2" || subChoice == "2.")
                {
                    savAccount.DeductBalance();
                    Console.WriteLine("Would you like to do something else? (Yes/No)");
                    if (Console.ReadLine().ToUpper() == "YES")
                    {
                        goto Start;
                    }
                    else
                    {
                        Console.WriteLine("Thank you for banking with WCCI Bank!");
                        Environment.Exit(0);
                    }
                }
                while (subChoice.ToUpper() == "EXIT")
                {
                    Console.WriteLine("Thank you for banking with WCCI Bank!");
                    Environment.Exit(0);
                }
            }

            //Exit
            while (userChoice == "5" || userChoice == "5." || userChoice.ToUpper() == "EXIT")
            {
                Console.WriteLine("Thank you for banking with WCCI Bank!");
                Environment.Exit(0);
            }
        }
Exemplo n.º 23
0
        static void Main(string[] args)
        {
            Client          nietzsche         = new Client("Friedrich", "Nietzsche", 1532980, 2968351);
            CheckingAccount nietzscheChecking = new CheckingAccount();
            SavingsAccount  nietzscheSavings  = new SavingsAccount();
            // user menu
            int    userChoice = 0;
            string userChoiceMenu;

            do
            {
                Console.WriteLine("Welcome to the bank account program.");
                Console.WriteLine("");
                Console.WriteLine("Please select one of the following options:");
                Console.WriteLine("[1] View client information.");
                Console.WriteLine("[2] View account balance:");
                Console.WriteLine("    [ ] Checking account balance.");
                Console.WriteLine("    [ ] Savings account balance.");
                Console.WriteLine("[3] Deposit funds:");
                Console.WriteLine("    [ ] In checking account.");
                Console.WriteLine("    [ ] In savings account.");
                Console.WriteLine("[4] Withdraw funds:");
                Console.WriteLine("    [ ] From checking account.");
                Console.WriteLine("    [ ] From savings account.");
                Console.WriteLine("[5] Exit.");
                userChoice = int.Parse(Console.ReadLine());
                switch (userChoice)
                {
                case 1:
                    nietzsche.DisplayAccountInformation();
                    Console.WriteLine("Press any key to continue.");
                    Console.ReadLine();
                    Console.Clear();
                    break;

                case 2:
                    Console.WriteLine("To check your checking acccount balance, type \"checking.\"");
                    Console.WriteLine("To check your savings account balance, type \"savings.\"");
                    userChoiceMenu = Console.ReadLine().ToLower();
                    if (userChoiceMenu == "checking")
                    {
                        Console.WriteLine("Your balance is $" + nietzscheChecking.CheckBalance());
                    }
                    else
                    {
                        Console.WriteLine("Your balance is $" + nietzscheSavings.CheckBalance());
                    }
                    Console.WriteLine("Press any key to continue.");
                    Console.ReadLine();
                    Console.Clear();
                    break;

                case 3:
                    Console.WriteLine("To deposit funds into your checking account, type \"checking.\"");
                    Console.WriteLine("To deposit funds into your savings account, type \"savings.\"");
                    userChoiceMenu = Console.ReadLine().ToLower();
                    if (userChoiceMenu == "checking")
                    {
                        nietzscheChecking.Deposit();
                    }
                    else
                    {
                        nietzscheSavings.Deposit();
                    }
                    Console.WriteLine("Press any key to continue.");
                    Console.ReadLine();
                    Console.Clear();
                    break;

                case 4:
                    Console.WriteLine("To withdraw funds from your checking account, type \"checking.\"");
                    Console.WriteLine("To withdraw funds from your savings account, type \"savings.\"");
                    userChoiceMenu = Console.ReadLine().ToLower();
                    if (userChoiceMenu == "checking")
                    {
                        nietzscheChecking.Withdraw();
                    }
                    else
                    {
                        nietzscheSavings.Withdraw();
                    }
                    Console.WriteLine("Press any key to continue.");
                    Console.ReadLine();
                    Console.Clear();
                    break;
                }
            } while (userChoice != 5);
        }