OfalzaDenz / IT2105

0 stars 0 forks source link

IT2105_LabActivity5_OFALZA #3

Open OfalzaDenz opened 4 days ago

OfalzaDenz commented 4 days ago

using System;

public class HelloWorld { private static int[] balance ={0};

public static void Main(string[] args)
{
    while (true)
    {
        Console.WriteLine(); 
        Console.WriteLine("Bank Account Menu:\n1. Deposit\n2. Withdraw\n3. Check Balance\n4. Exit");
        Console.Write("Choose an option (1-4): ");
        int choice = Convert.ToInt32(Console.ReadLine());
        switch (choice)
        {
            case 1:
                Deposit();
                break;
            case 2:
                Withdraw();
                break;
            case 3:
                Console.WriteLine($"Your current balance is: ${balance[0]}");
                break;
            case 4:
                return;
            default:
                Console.Write("Invalid option.");
                break;
        }
    }
}

static void Deposit()
{
    Console.Write("Enter the amount to deposit: ");
    int dp = Convert.ToInt32(Console.ReadLine());
    balance [0] = dp;
    Console.WriteLine($"${dp} has been deposited to your account.");
}

static void Withdraw()
{
    Console.Write("Enter the amount to withdraw: ");
    int wt = Convert.ToInt32(Console.ReadLine());
    balance [0] = wt;
    Console.WriteLine($"${wt} has been withdrawn from your account.");
}

}