Advertisement
Guest User

Untitled

a guest
May 27th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.49 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApp1
  8. {
  9. class CreateAccount
  10. {
  11. static void Main(string[] args)
  12. {
  13. Console.WriteLine("An applicatino modeling the handling of all bank accounts");
  14.  
  15. //BankAccount account1 = new BankAccount();
  16. //BankAccount account2 = new BankAccount();
  17.  
  18. //account1.accountType = "Current";
  19. //account1.accountNumber = 123;
  20. //account1.accountBalance = 1000.00;
  21. //Console.WriteLine("Account Number: " + account1.accountNumber);
  22. //Console.WriteLine("Account Type: " + account1.accountType);
  23. //Console.WriteLine("Account Balance: " + account1.accountBalance);
  24. //account1.accountNumber = long.Parse(Console.ReadLine());
  25.  
  26. //account2.accountType = "Savings";
  27. //account2.accountNumber = 124;
  28. //account2.accountBalance = 2000.00;
  29. //Console.WriteLine("Account Number: " + account2.accountNumber);
  30. //Console.WriteLine("Account Type: " + account2.accountType);
  31. //Console.WriteLine("Account Balance: " + account2.accountBalance);
  32.  
  33. BankAccount kowalski = NewBankAccount();
  34. PrintAccount(kowalski);
  35. BankAccount nowak = NewBankAccount();
  36. PrintAccount(nowak);
  37. }
  38. static BankAccount NewBankAccount()
  39. {
  40. BankAccount newAccount = new BankAccount();
  41. try
  42. {
  43. Console.Write("Enter the account number");
  44. newAccount.accountNumber = long.Parse(Console.ReadLine());
  45. Console.Write("Enter the account type: ");
  46. newAccount.accountType = Console.ReadLine();
  47. Console.Write("Enter the account balance");
  48. newAccount.accountBalance = double.Parse(Console.ReadLine());
  49. }
  50. catch (System.FormatException e)
  51. {
  52. Console.WriteLine("An exeption when reading the keyboard appeared:" + e);
  53. }
  54. return newAccount;
  55. }
  56. static void PrintAccount(BankAccount account)
  57. {
  58. Console.WriteLine("Account number: " + account.accountNumber);
  59. Console.WriteLine("Account type : " + account.accountType);
  60. Console.WriteLine("Account balance: " + account.accountBalance);
  61. }
  62. }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement