Example #1
0
        static void Main(string[] args)
        {
            SavingsAccount  sAccount = new SavingsAccount(5.00, 2.0);
            ChequingAccount cAccount = new ChequingAccount(5.00, 2.0);
            GlobalSavings   gAccount = new GlobalSavings(5.00, 2.0);

            string userOption = "";

            do
            {
                Console.WriteLine("Bank Menu\n" +
                                  "A: Savings Account\n" +
                                  "B: Checking Account\n" +
                                  "C: Global Savings Account\n" +
                                  "Q: Exit\n");

                userOption = Console.ReadKey().Key.ToString();
                Console.WriteLine();

                while (userOption != "A" && userOption != "B" && userOption != "C" && userOption != "Q")
                {
                    Console.WriteLine("Enter A, B, C or Q.");
                    userOption = Console.ReadKey().Key.ToString();
                    Console.WriteLine();
                }

                switch (userOption)
                {
                // SAVINGS MENU
                case "A":
                    do
                    {
                        Console.WriteLine("\nSavings Account Menu\n" +
                                          "A: Deposit\n" +
                                          "B: Withdrawal\n" +
                                          "C: Close + Report\n" +
                                          "R: Return to Bank Menu\n");

                        userOption = Console.ReadKey().Key.ToString();
                        Console.WriteLine();

                        while (userOption != "A" && userOption != "B" && userOption != "C" && userOption != "R")
                        {
                            Console.WriteLine("Enter A, B, C or R.");
                            userOption = Console.ReadKey().Key.ToString();
                            Console.WriteLine();
                        }

                        switch (userOption)
                        {
                        case "A":

                            string tempAmount    = "";
                            double depositAmount = -1;
                            bool   validNumber   = false;

                            while (!validNumber)
                            {
                                Console.WriteLine("\nEnter a valid amount to deposit.");
                                tempAmount = Console.ReadLine();

                                double outNum    = -1;
                                bool   isNumeric = Double.TryParse(tempAmount, out outNum);

                                if (isNumeric && outNum >= 0)
                                {
                                    depositAmount = outNum;
                                    validNumber   = true;
                                }
                            }

                            sAccount.MakeDeposit(depositAmount);
                            break;

                        case "B":
                            double withdrawAmount = -1;
                            validNumber = false;

                            while (!validNumber)
                            {
                                Console.WriteLine("\nEnter a valid amount to withdraw.");
                                tempAmount = Console.ReadLine();

                                double outNum    = -1;
                                bool   isNumeric = Double.TryParse(tempAmount, out outNum);

                                if (isNumeric && outNum >= 0)
                                {
                                    withdrawAmount = outNum;
                                    validNumber    = true;
                                }
                            }

                            sAccount.MakeWithdraw(withdrawAmount);
                            break;

                        case "C":
                            sAccount.CloseAndReport();
                            break;
                        }
                    } while (userOption != "R");
                    break;

                // CHECKINGS MENU
                case "B":
                    do
                    {
                        Console.WriteLine("\nCheckings Account Menu\n" +
                                          "A: Deposit\n" +
                                          "B: Withdrawal\n" +
                                          "C: Close + Report\n" +
                                          "R: Return to Bank Menu\n");

                        userOption = Console.ReadKey().Key.ToString();
                        Console.WriteLine();

                        while (userOption != "A" && userOption != "B" && userOption != "C" && userOption != "R")
                        {
                            Console.WriteLine("Enter A, B, C or R.");
                            userOption = Console.ReadKey().Key.ToString();
                            Console.WriteLine();
                        }

                        switch (userOption)
                        {
                        case "A":

                            string tempAmount    = "";
                            double depositAmount = -1;
                            bool   validNumber   = false;

                            while (!validNumber)
                            {
                                Console.WriteLine("\nEnter a valid amount to deposit.");
                                tempAmount = Console.ReadLine();

                                double outNum    = -1;
                                bool   isNumeric = Double.TryParse(tempAmount, out outNum);

                                if (isNumeric && outNum >= 0)
                                {
                                    depositAmount = outNum;
                                    validNumber   = true;
                                }
                            }

                            cAccount.MakeDeposit(depositAmount);
                            break;

                        case "B":
                            double withdrawAmount = -1;
                            validNumber = false;

                            while (!validNumber)
                            {
                                Console.WriteLine("\nEnter a valid amount to withdraw.");
                                tempAmount = Console.ReadLine();

                                double outNum    = -1;
                                bool   isNumeric = Double.TryParse(tempAmount, out outNum);

                                if (isNumeric && outNum >= 0)
                                {
                                    withdrawAmount = outNum;
                                    validNumber    = true;
                                }
                            }

                            cAccount.MakeWithdraw(withdrawAmount);
                            break;

                        case "C":
                            cAccount.CloseAndReport();
                            break;
                        }
                    } while (userOption != "R");
                    break;

                // GLOBAL SAVINGS MENU
                case "C":
                    do
                    {
                        Console.WriteLine("\nGlobal Savings Account Menu\n" +
                                          "A: Deposit\n" +
                                          "B: Withdrawal\n" +
                                          "C: Close + Report\n" +
                                          "D: Report Balance in USD\n" +
                                          "R: Return to Bank Menu\n");

                        userOption = Console.ReadKey().Key.ToString();
                        Console.WriteLine();

                        while (userOption != "A" && userOption != "B" && userOption != "C" && userOption != "D" && userOption != "R")
                        {
                            Console.WriteLine("\nEnter A, B, C, D or R.");
                            userOption = Console.ReadKey().Key.ToString();
                            Console.WriteLine();
                        }

                        switch (userOption)
                        {
                        case "A":
                            string tempAmount    = "";
                            double depositAmount = -1;
                            bool   validNumber   = false;

                            while (!validNumber)
                            {
                                Console.WriteLine("\nEnter a valid amount to deposit.");
                                tempAmount = Console.ReadLine();

                                double outNum    = -1;
                                bool   isNumeric = Double.TryParse(tempAmount, out outNum);

                                if (isNumeric && outNum >= 0)
                                {
                                    depositAmount = outNum;
                                    validNumber   = true;
                                }
                            }

                            gAccount.MakeDeposit(depositAmount);
                            break;

                        case "B":
                            double withdrawAmount = -1;
                            validNumber = false;

                            while (!validNumber)
                            {
                                Console.WriteLine("\nEnter a valid amount to withdraw.");
                                tempAmount = Console.ReadLine();

                                double outNum    = -1;
                                bool   isNumeric = Double.TryParse(tempAmount, out outNum);

                                if (isNumeric && outNum >= 0)
                                {
                                    withdrawAmount = outNum;
                                    validNumber    = true;
                                }
                            }

                            gAccount.MakeWithdraw(withdrawAmount);
                            break;

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

                        case "D":
                            Console.WriteLine(String.Format("\nAccount Balance: USD{0:C2}", gAccount.USValue(0.76335878)));
                            break;
                        }
                    } while (userOption != "R");
                    break;
                }
            } while (userOption != "Q");
        }
Example #2
0
        static void Main(string[] args)
        {
            string choice, accountName, dob, address;

            Random rnd       = new Random();
            int    accountNo = rnd.Next(100, 1000);

            accountNo++;

            Bank bank = new Bank("YO Bank", 1000);

            Console.WriteLine("-----------------------------------------");
            Console.WriteLine("<><><><> Welcome to NoName Bank! <><><><>");
            Console.WriteLine("-----------------------------------------");

            //for(int i = 0; i<10; i++)
            //{
            bool repeat = true;

            while (repeat)
            {
                Console.WriteLine("<><><><> Here are your Options: <><><><>");
                Console.WriteLine("Open a Bank account");
                Console.WriteLine("Perform transactions for an account");
                Console.WriteLine("Exit the application");
                Console.WriteLine("-----------------------------------------");
                Console.WriteLine("Enter your choice: ");
                choice = Console.ReadLine();

                switch (choice)
                {
                case "open":
                {
                    Console.WriteLine("-----------------------------------------");
                    Console.WriteLine("Open Savings Account");
                    Console.WriteLine("Open Checking Account");
                    Console.WriteLine("Exit from the application");
                    Console.WriteLine("-----------------------------------------");
                    Console.WriteLine("Enter your choice: ");
                    string choice1 = Console.ReadLine();

                    if (choice1 == "quit")
                    {
                        break;
                    }
                    else if (choice1 == "savings")
                    {
                        Console.WriteLine("Enter Your Name : ");
                        accountName = Console.ReadLine();
                        Console.WriteLine();

                        Console.WriteLine("Enter Date of Birth :");
                        dob = Console.ReadLine();
                        Console.WriteLine();

                        Console.WriteLine("Enter Adress :");
                        address = Console.ReadLine();
                        Console.WriteLine();

                        Console.WriteLine("Enter Balance :");
                        string balance1 = Console.ReadLine();
                        int    b1       = Convert.ToInt32(balance1);
                        Console.WriteLine();

                        SavingsAccount sa = new SavingsAccount(accountNo, accountName, b1, dob, address);
                    }
                    else if (choice1 == "checking")
                    {
                        Console.WriteLine("Enter Your Name : ");
                        accountName = Console.ReadLine();
                        Console.WriteLine();

                        Console.WriteLine("Enter Date of Birth :");
                        dob = Console.ReadLine();
                        Console.WriteLine();

                        Console.WriteLine("Enter Adress :");
                        address = Console.ReadLine();
                        Console.WriteLine();

                        Console.WriteLine("Enter Balance :");
                        string balance1 = Console.ReadLine();
                        int    b1       = Convert.ToInt32(balance1);
                        Console.WriteLine();
                    }
                    break;
                }

                case "account":
                {
                    Console.WriteLine("-----------------------------------------");
                    Console.WriteLine("Make a deposit");
                    Console.WriteLine("Make a withdrawal");
                    Console.WriteLine("Make a transfer");
                    Console.WriteLine("Show the number transactions and balance");
                    Console.WriteLine("Exit the application");
                    Console.WriteLine("-----------------------------------------");
                    Console.WriteLine("Enter your choice: ");
                    string choice2 = Console.ReadLine();

                    if (choice2 == "quit")
                    {
                        break;
                    }
                    else if (choice2 == "deposit")
                    {
                        bank.PerformTransactions("deposit");
                    }
                    else if (choice2 == "withdraw")
                    {
                        bank.PerformTransactions("withdraw");
                    }
                    else if (choice2 == "transfer")
                    {
                        bank.PerformTransactions("transfer");
                    }
                    else if (choice2 == "show")
                    {
                        bank.PerformTransactions("show");
                    }
                    break;
                }

                case "quit":
                    return;

                default:
                    Console.WriteLine("Sorry, Wrong Input!");
                    break;
                }
            }
        }
Example #3
0
 private void Form1_Load(object sender, EventArgs e)
 {
     aCheckingAccount = new CheckingAccount("Mark Whalberg", 2948564, 8500.00, 7, 2.75, 0.00, 0.00);
     aSavingsAccount  = new SavingsAccount("Mickey Mouse", 904736, 100000000, 5.00, 10);
 }