Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace atm_program
- {
- public class Program
- {
- static void Main(string[] args)
- {
- string screen;
- int menupick = -1;
- Account myAccount = null;
- while (myAccount == null)
- {
- Console.WriteLine("Welcome to Regions Bank");
- Console.WriteLine("Please Select an Account");
- Console.WriteLine("1. Checking");
- Console.WriteLine("2. Savings");
- screen = Console.ReadLine();
- if(int.TryParse(screen, out menupick))
- {
- if (menupick == 1)
- myAccount = new Checking(8527419630);
- else if (menupick == 2)
- myAccount = new Savings(852741520);
- else
- Console.WriteLine("Error: Invalid Operation");
- }
- else
- {
- Console.WriteLine("You must select an operation to proceed.");
- }
- }
- while (menupick != 0)
- {
- Console.WriteLine();
- Console.WriteLine("1. Account Status");
- Console.WriteLine("2. Make Deposit");
- Console.WriteLine("3. Make Withdrawal");
- Console.WriteLine("0. Quit");
- Console.WriteLine();
- Console.Write("Enter Command: ");
- screen = Console.ReadLine();
- if (int.TryParse(screen, out menupick))
- {
- switch (menupick)
- {
- case 0:
- Console.WriteLine("Thank you for choosing the Bank. Goodbye!");
- break;
- case 1:
- ShowStatus(myAccount);
- break;
- case 2:
- MakeDeposit(myAccount);
- break;
- case 3:
- MakeWithdrawal(myAccount);
- break;
- default:
- Console.WriteLine("Invalid Command!");
- menupick = -1;
- break;
- }
- }
- else
- {
- Console.WriteLine("Invalid Command!");
- menupick = -1;
- }
- }
- Pause();
- }
- static void ShowStatus(Account account)
- {
- Console.WriteLine("------- Account Status -------");
- Console.WriteLine(" Account Number: {0}", account.AcctNo);
- Console.WriteLine(" Total Balance: {0}", account.Balance);
- Console.WriteLine("--------------------------------");
- }
- static void MakeDeposit(Account account)
- {
- string screen;
- double amount;
- Console.Write("Enter an amount you would like to deposit (must be a positive number):");
- screen = Console.ReadLine();
- if (double.TryParse(screen, out amount))
- {
- Account.Deposit(amount);
- Console.WriteLine("New Balance" + Account.Balance);
- }
- else
- {
- Console.WriteLine("Error: invalid number. Please try again.");
- }
- }
- private static void MakeWithdrawal(Account account)
- {
- string screen;
- double amount;
- Console.Write("Enter an amount you would like to withdraw");
- screen = Console.ReadLine();
- if (double.TryParse(screen, out amount))
- {
- Account.Withdrawal(amount);
- Console.WriteLine("New Balance" + Account.Balance);
- }
- else
- {
- Console.WriteLine("Error: invalid number. Please try again.");
- }
- }
- static void Pause()
- {
- Console.WriteLine();
- Console.Write("Press any key to continue... ");
- Console.ReadKey();
- Console.WriteLine("\r \r");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement