Example #1
0
        public static void MenuGS(GlobalSavingsAccount AGS)
        {
            string optionGS;

            Regex Rgx = new Regex(@"\d+\.\d+");

            do
            {
                Console.WriteLine("You accessed the Global Savings page:");

                Console.WriteLine(String.Format("A. Deposit\nB. Withdraw\nC. Close + Report\nD. Report Balance in USD\nR. Go Back"));
                optionGS = Console.ReadLine().ToUpper();

                switch (optionGS)
                {
                case "A":
                    Console.WriteLine("Enter the amount you want to deposit:");
                    string stringAmountD = Console.ReadLine();
                    if (!(Rgx.IsMatch(stringAmountD)))
                    {
                        throw new FormatException("The number you entered is not acceptable");
                    }
                    double.TryParse(stringAmountD, out double userAmountD);
                    AGS.MakeDeposit(userAmountD);
                    break;

                case "B":
                    Console.WriteLine("Enter the amount you want to withdraw:");
                    string stringAmountW = Console.ReadLine();
                    if (!(Rgx.IsMatch(stringAmountW)))
                    {
                        throw new FormatException("The number you entered is not acceptable");
                    }
                    double.TryParse(stringAmountW, out double userAmountW);
                    AGS.MakeWithdrawl(userAmountW);
                    break;

                case "C":
                    Console.WriteLine(AGS.CloseAndReport());
                    Console.WriteLine("The values yield a change of: {0:F2}%", AGS.GetPercentageChange());
                    break;

                case "D":
                    Console.WriteLine(AGS.USValue(0.76).toNAMoney(true));
                    break;

                case "R":
                    break;

                default:
                    throw new InvalidOperationException("That's not what I'm looking for...");
                }
            }while (optionGS != "R");
        }
Example #2
0
        static void Main(string[] args)
        {
            Account A1 = new SavingsAccount(5.00, .02);
            Account A2 = new ChequingAccount(5.00, .02);
            GlobalSavingsAccount A3 = new GlobalSavingsAccount(5.00, .02);

            string option;

            Console.WriteLine("You booted up the Personal Bank App!");
            do
            {
                Console.WriteLine("You accessed the General page:");

                Console.WriteLine(String.Format("A. Savings\nB. Checking\nC. Global Savings\nQ. Exit"));
                option = Console.ReadLine().ToUpper();

                switch (option)
                {
                case "A":
                    MenuS(A1);
                    break;

                case "B":
                    MenuC(A2);
                    break;

                case "C":
                    MenuGS(A3);
                    break;

                case "Q":
                    Environment.Exit(0);
                    break;

                default:
                    throw new InvalidOperationException("That's not what I'm looking for...");
                }
            }while(option != "Q");
        }
Example #3
0
        static void Main(string[] args)
        {
            Chequins             check = new Chequins(25.00, 0.12, 3.99);
            Savings              save  = new Savings(25.00, 0.12, 3.99, true);
            GlobalSavingsAccount gsa   = new GlobalSavingsAccount(25.00, 0.12, 3.99, true);

            bool loop = true;

            while (loop == true)
            {
                StringBuilder sb = new StringBuilder();

                sb.AppendFormat("***Welcome to Scotia Bank Personal Banking***\n***Bank Menu***\nA.Savings Account\nB.Checkings Account\nC.Gloabl Savings Account\nQ.Quit");
                Console.WriteLine(sb);
                string line = Console.ReadLine();

                if (line.Equals("Q", StringComparison.OrdinalIgnoreCase))
                {
                    break;
                }



                switch (line.ToLower())
                {
                case "a":
                    Console.WriteLine("***Savings Menu***");
                    Console.WriteLine("A. Deposit");
                    Console.WriteLine("B. withdrawl");
                    Console.WriteLine("C. Close and Report");
                    Console.WriteLine("R. Return to Menu");
                    string mainInp1 = Console.ReadLine();


                    switch (mainInp1.ToLower())
                    {
                    case "a":


                        Console.WriteLine("How much would you like to deposit?");
                        double sav1 = Convert.ToDouble(Console.ReadLine());

                        Console.WriteLine("Your Balance is now: {0}", save.makeDeposit(sav1));
                        Console.WriteLine("Press any key to continue");
                        string user = Console.ReadLine();

                        if (user.Equals(ConsoleKey.Y))
                        {
                            continue;
                        }
                        break;

                    case "b":
                        Console.WriteLine("How much would you like to withdrawl?");
                        double sav2 = Convert.ToDouble(Console.ReadLine());

                        Console.WriteLine("Your Balance is now: {0}", save.makeWithdrawl(sav2));
                        Console.WriteLine("press any key to continue");
                        string user1 = Console.ReadLine();

                        if (user1.Equals(ConsoleKey.Y))
                        {
                            continue;
                        }

                        break;

                    case "c":
                        Console.WriteLine("Close and report Status: ");
                        string sav3 = save.closeAndReport();
                        Console.WriteLine(sav3);

                        Console.WriteLine("press any key to continue");
                        string user2 = Console.ReadLine();

                        if (user2.Equals(ConsoleKey.Y))
                        {
                            continue;
                        }
                        break;

                    case "r":
                        if (mainInp1.Equals(ConsoleKey.R))
                        {
                            Console.WriteLine(sb);
                            line = Console.ReadLine();
                        }
                        break;
                    }
                    break;


                case "b":
                    Console.WriteLine("***Checkings Menu***");
                    Console.WriteLine("A. Deposit");
                    Console.WriteLine("B. withdrawl");
                    Console.WriteLine("C. Close and Report");
                    Console.WriteLine("R. Return to Menu");

                    string mainInp2 = Console.ReadLine();

                    switch (mainInp2.ToLower())
                    {
                    case "a":
                        Console.WriteLine("How much would you like to deposit?");
                        double check1 = Convert.ToDouble(Console.ReadLine());

                        Console.WriteLine("Your Balance is now: {0}", check.makeDeposit(check1));
                        Console.WriteLine("Press any key to continue");
                        string user1 = Console.ReadLine();

                        while (user1.Equals(ConsoleKey.Y))
                        {
                            continue;
                        }
                        break;

                    case "b":
                        Console.WriteLine("How much would you like to withdrawl?");
                        double check2 = Convert.ToDouble(Console.ReadLine());

                        Console.WriteLine("Your Balance is now: {0}", check.makeWithdrawl(check2));
                        Console.WriteLine("Press any key to continue");
                        string user2 = Console.ReadLine();

                        while (user2.Equals(ConsoleKey.Y))
                        {
                            continue;
                        }
                        break;

                    case "c":
                        Console.WriteLine("Close and report Status: ");
                        string check3 = check.closeAndReport(3.99);
                        Console.WriteLine(check3);
                        Console.WriteLine("Press any key to continue");
                        string user3 = Console.ReadLine();

                        while (user3.Equals(ConsoleKey.Y))
                        {
                            continue;
                        }
                        break;

                    case "r":
                        if (mainInp2.Equals(ConsoleKey.R))
                        {
                            Console.WriteLine(sb);
                            line = Console.ReadLine();
                        }
                        break;
                    }



                    break;

                case "c":
                    Console.WriteLine("***Global Savings Menu***");
                    Console.WriteLine("A. Deposit");
                    Console.WriteLine("B. withdrawl");
                    Console.WriteLine("C. Close and Report");
                    Console.WriteLine("D.Report Balance in USD");
                    Console.WriteLine("R. Return to Menu");
                    string mainInp3 = Console.ReadLine();

                    switch (mainInp3.ToLower())
                    {
                    case "a":
                        Console.WriteLine("How much would you like to deposit?");
                        double gsa1 = Convert.ToDouble(Console.ReadLine());

                        Console.WriteLine("Your Balance is now: {0}", gsa.makeDeposit(gsa1));

                        Console.WriteLine("Press any key to continue");
                        string user1 = Console.ReadLine();

                        if (user1.Equals(ConsoleKey.Y))
                        {
                            continue;
                        }
                        break;

                    case "b":
                        Console.WriteLine("How much would you like to withdrawl?");
                        double gsa2 = Convert.ToDouble(Console.ReadLine());

                        Console.WriteLine("Your Balance is now: {0}", gsa.makeWithdrawl(gsa2));

                        Console.WriteLine("Press any key to continue");
                        string user2 = Console.ReadLine();

                        while (user2.Equals(ConsoleKey.Y))
                        {
                            continue;
                        }
                        break;

                    case "c":
                        Console.WriteLine("Close and report Status: ");
                        string gsa3 = gsa.closeandReport();
                        Console.WriteLine(gsa3);
                        Console.WriteLine("Press any key to continue");
                        string user3 = Console.ReadLine();

                        if (user3.Equals(ConsoleKey.Y))
                        {
                            continue;
                        }
                        else if (user3.Equals(ConsoleKey.N))
                        {
                            break;
                        }
                        break;

                    case "d":
                        Console.WriteLine("your amount in USD is: {0}", gsa.USValue(0.75));
                        Console.WriteLine("Press any key to continue");
                        string user4 = Console.ReadLine();

                        if (user4.Equals(ConsoleKey.Y))
                        {
                            continue;
                        }
                        break;

                    case "r":
                        if (mainInp3.Equals(ConsoleKey.R))
                        {
                            Console.WriteLine(sb);
                            line = Console.ReadLine();
                        }
                        break;
                    }

                    break;

                case "q":
                    break;
                }
            }
        }
Example #4
0
        public static void GlobalSavingsMenu()
        {
            try
            {
                GlobalSavingsAccount global = new GlobalSavingsAccount(5, 1.00);
                StringBuilder        sb     = new StringBuilder();
                sb.Append("Global Savings Menu\n");
                sb.Append("A. Deposit\n");
                sb.Append("B. Withdrawal\n");
                sb.Append("C. Close + Report\n");
                sb.Append("D. Report Balance in USD");
                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)
                            {
                                global.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)
                            {
                                global.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":
                    global.CloseAndReport();
                    break;

                case "D":
                    Console.WriteLine(global.GetPercentageChange());
                    break;

                case "R":
                    MainMenu();
                    break;

                default:
                    throw new IllegalSavingsMenuOptionException("Unkown option \"" + sinput + "\"");
                }
            }
            catch (IllegalSavingsMenuOptionException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }