test5555
public
Jul 31, 2024
Never
53
1 // Bank App.cs 2 3 using System; 4 using System.Diagnostics.Eventing.Reader; 5 using System.Linq; 6 using System.Threading; 7 8 internal class Program 9 { 10 private static int balance = 1000; 11 private static int pinNumber = 6749; // namespace.variable 12 13 private static void Main(string[] args) 14 { 15 16 Console.WriteLine("[DEBUG] Your Pin: " + Program.pinNumber); 17 18 Console.Write("Please Enter Pin: "); 19 string userInput = Console.ReadLine(); 20 21 if (int.TryParse(userInput, out int pinNumberInput)) 22 { 23 if (pinNumber == pinNumberInput) 24 { 25 Console.WriteLine("Correct!"); 26 AccessGranted(); 27 28 } 29 else 30 { 31 Console.WriteLine("ERROR | Try Again!"); 32 } 33 } 34 else 35 { 36 Console.WriteLine("Invalid input. Please enter a numeric pin."); 37 } 38 39 40 Console.ReadLine(); 41 } 42 43 private static void AccessGranted() 44 { 45 46 Console.Clear(); 47 Console.WriteLine("Access Granted! Welcome!"); 48 Console.Write("Current Balance: "); 49 Console.ForegroundColor = ConsoleColor.Green; 50 Console.WriteLine(Program.balance); 51 Console.ResetColor(); 52 53 string[] Mode1 = { "Withdraw", "Withdrawl", "w" }; 54 string[] Mode2 = { "Deposit", "deposit", "d" }; 55 56 Console.WriteLine("Do you want to Withdrawl or Deposit?: "); 57 string InputBankMode = Console.ReadLine(); 58 59 if (Mode1.Contains(InputBankMode)) 60 { 61 Console.WriteLine("You have chosen to withdrawl"); 62 Thread.Sleep(2000); 63 Console.Clear(); 64 UserCheckBalence(); 65 } 66 else if (Mode2.Contains(InputBankMode)) 67 { 68 Console.WriteLine("You have chosen to Deposit"); 69 Thread.Sleep(2000); 70 Console.Clear(); 71 AccessGranted(); 72 } 73 else 74 { 75 Console.WriteLine("ERROR | Try Again!"); 76 Thread.Sleep(5000); 77 Console.Clear(); 78 AccessGranted(); 79 80 } 81 } 82 83 private static void UserCheckBalence() // check if able to withdrawl 84 { 85 Console.WriteLine("Current Balance: " + Program.balance); 86 87 if (Program.balance < 1) 88 { 89 Console.Clear(); 90 Console.WriteLine("You are too poor , earn more cash!"); 91 Console.WriteLine(""); 92 AccessGranted(); 93 94 95 } 96 else 97 { 98 Withdrawl(); 99 } 100 101 } 102 private static void Withdrawl() 103 { 104 105 106 Console.WriteLine("How much money would you like to withdrawl?"); 107 string input = Console.ReadLine(); 108 if (!int.TryParse(input, out int withDrawl_Ammount)) 109 return; 110 111 Console.WriteLine($"You have chosen {withDrawl_Ammount}"); 112 int NewBalence = Program.balance - withDrawl_Ammount; 113 114 115 if (NewBalence <= 0) 116 { 117 Console.WriteLine("Invalid withdrawal amount."); 118 return; 119 120 } 121 if (Program.balance < withDrawl_Ammount) 122 { 123 Console.WriteLine("Insufficient funds."); 124 return; 125 } 126 Console.WriteLine($"New Balence: {NewBalence}"); 127 128 129 } 130 } 131