Momo-html / IT2105

0 stars 0 forks source link

IT2105_LabActivity5_Bael #3

Open Momo-html opened 3 weeks ago

Momo-html commented 3 weeks ago

using System;

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

public static void Main(string[] args)
{

    while(true)
    {
    Console.WriteLine ("Bank Account Menu; \n 1. Deposit \n 2. Withdraw \n 3. Check Balance \n 4. 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: ${acc[0]}");
        break;
        case 4:
        return;
        default:
        Console.WriteLine("Invalid Choice.");
        break;
    }   
    Console.WriteLine();
    }

}
static void Deposit()    
{
    Console.Write("Enter Amount to Deposit: ");
            int dep = Convert.ToInt32(Console.ReadLine());
            acc[0] = acc[0] + dep;
            Console.WriteLine($"${dep} has been deposited to your account.");

}

static void Withdraw()
{
    Console.Write("Enter Amount to Withdraw: ");
        int with = Convert.ToInt32(Console.ReadLine());
        acc[0] = acc[0] - with;
        Console.WriteLine($"${acc[0]} has been withdrawn from your acount.");
}

}

Momo-html commented 3 weeks ago

image