Answer to Question #327589 in C# for Kunal

Question #327589

Let’s build a sample banking program to perform the common tasks like Withdraw and Deposit. 


1
Expert's answer
2022-04-12T16:15:44-0400
   class Bank
    {
        public decimal BankAccount { get; set; }
        public Bank(decimal bankAccount)
        {
            BankAccount = bankAccount;
        }


        public void Withdraw(decimal amount)
        {
            BankAccount -= amount;
            Console.WriteLine($"Withdrawn from your account: {amount}.Amount in your account: {BankAccount}");
        }


        public void Deposit(decimal amount)
        {
            BankAccount += amount;
            Console.WriteLine($"Credited to your account: {amount}.Amount in your account: {BankAccount}");
        }
    }


    static void Main()
    {
        Console.Write("Enter the initial amount in your bank account:");
        Bank bank = new Bank(decimal.Parse(Console.ReadLine()));
        Console.Write("Enter how much money you want to withdraw from your bank account:");
        bank.Withdraw(decimal.Parse(Console.ReadLine()));
        Console.Write("Enter how much you want to credit to your bank account:");
        bank.Deposit(decimal.Parse(Console.ReadLine()));
        Console.ReadKey();
    }

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