Answer to Question #285769 in C# for LIRCY

Question #285769

imagine an atm machine, menus include balance inquiry, deposit, withdrawals and exit. write a method or function for each menu. the initial balance is d

1
Expert's answer
2022-01-09T10:43:39-0500
using System;
using System.Threading;

namespace Bank
{
    internal class Program
    {
        public static void Main()
        {
            // imagine an atm machine, menus include balance inquiry, deposit, withdrawals and exit.
            // write a method or function for each menu. the initial balance is d
           
            while (true)
            {
                Console.WriteLine("\t\t\t\t\t\t\t Select an action");
                Console.WriteLine("1 = Get Balance");
                Console.WriteLine("2 = Your Deposit");
                Console.WriteLine("3 = Withdrawals");
                Console.WriteLine("4 = Exit");
                Console.Write("Enter action number: ");
                int action = int.Parse(Console.ReadLine());
                int d = 5000;
                switch (action)
                {
                    case 1: Console.WriteLine("Your Balance: " + Get_Balance(d)); break;
                    case 2: Console.Write("Your Deposit: " + Deposit(d)); break;
                    case 3: Withdrawals(d); break;
                    case 4: return;
                    default: Console.Write("Please select an action:"); Thread.Sleep(3200); Console.Clear(); Main(); break;
                }
                Console.ReadLine();
                Console.Clear();
            }
        }

        static int Get_Balance(int balance)
        {
            return balance;
        }

        static int Deposit(int d)
        {
            return d;
        }

        static void Withdrawals(int money)
        {
            Console.Write("How much money do you want to withdraw: ");
            int get = int.Parse(Console.ReadLine());
            Console.WriteLine($"Your Balance {money-get}");
        }
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS