hi, create c# app that works as bankomate that will ask your pin and then about required…
- User
hi, create c# app that works as bankomate that will ask your pin and then about required operation
- Assistant
hi, create c# app that works as bankomate that will ask your pin and then about required operation
Sure! Here's an example of a C# console application that acts as a banking machine. It asks for a PIN number and provides various banking operations such as balance inquiry, cash withdrawal, and deposit.
using System;
namespace BankomatApp
{
class Program
{
static void Main(string[] args)
{
// Set a PIN number
int pin = 1234;
// Prompt user for PIN
Console.WriteLine("Welcome to the Bankomat App!");
Console.Write("Please enter your PIN: ");
int enteredPin = int.Parse(Console.ReadLine());
// Check PIN validity
if (enteredPin != pin)
{
Console.WriteLine("Invalid PIN. Exiting the program.");
return;
}
// Valid PIN, display menu options
bool exit = false;
decimal balance = 5000;
while (!exit)
{
Console.WriteLine("\nBankomat Menu:");
Console.WriteLine("1. Check Balance");
Console.WriteLine("2. Cash Withdrawal");
Console.WriteLine("3. Deposit");
Console.WriteLine("4. Exit");
Console.Write("Choose an option (1-4): ");
int option = int.Parse(Console.ReadLine());
switch (option)
{
case 1:
Console.WriteLine($"Your current balance is: ${balance}");
break;
case 2:
Console.Write("Enter the amount to withdraw: $");
decimal withdrawalAmount = decimal.Parse(Console.ReadLine());
if (balance >= withdrawalAmount)
{
balance -= withdrawalAmount;
Console.WriteLine($"Withdrawal successful. Updated balance: ${balance}");
}
else
{
Console.WriteLine("Insufficient balance for withdrawal.");
}
break;
case 3:
Console.Write("Enter the amount to deposit: $");
decimal depositAmount = decimal.Parse(Console.ReadLine());
balance += depositAmount;
Console.WriteLine($"Deposit successful. Updated balance: ${balance}");
break;
case 4:
Console.WriteLine("Thank you for using the Bankomat App. Have a nice day!");
exit = true;
break;
default:
Console.WriteLine("Invalid option. Please try again.");
break;
}
}
}
}
}
In this example, the PIN number is set to "1234" (you can change it accordingly). The user is prompted to enter the PIN. If the entered PIN matches the set PIN, the user is presented with a menu of options. Option 1 allows the user to check their account balance. Option 2 allows cash withdrawal (if the balance is sufficient). Option 3 allows the user to deposit money. Option 4 exits the program.
Feel free to modify the code to suit your needs or add additional functionality.