Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that will be an Automated Teller Machine (ATM). It will allow a

ID: 3559560 • Letter: W

Question

Write a program that will be an Automated Teller Machine (ATM). It will allow a customer to log in with a PIN number, check the PIN, and then allow the customer to withdraw money up to the balance in their account. The customer may also deposit money, and that money should be added to the current balance.

Since the program will not read from a database, declare 2 variables called MyPIN and MyBalance. Set these 2 variables to 1234 and 2,000.00 respectively.


o    When the program runs, ask for the PIN. Whatever input they type in, compare against MyPIN and only allow withdrawals or deposits if they are equal.


o    Give a short menu to the customer after the PIN is succesfully entered.


o    For example, 1. Withdrawal, 2. Deposit, 3. Log off.


o    Only allow the 3 options. Repeat the menu if incorrect.


o    When withdrawing, ask for the amount. Verify that that amount can be withdrawn, then "pretend" to give them the cash. Deduct from the current balance.


o    When depositing, ask for the amount. Make sure it is a valid amount. "Pretend" to let them deposit the money. Add to the current balance.


o    When the transaction is completed, show the menu again.


o    It is ok for the balance to be reset each time the program is run.

Explanation / Answer

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtmClassLibrary
{
    public class Account
    {
        private int m_AccountNumber;
        private string m_AccountName;
        private string MyPin;
        private int m_CardLimit;
        private int MyBalance;

        public int AccountNumber
        {
            get { return m_AccountNumber; }
            set { m_AccountNumber = value; }
        }
        public string AccountName
        {
            get { return m_AccountName; }
            set { m_AccountName = value; }
        }
        public string Id
        {
            get { return MyPin; }
            set { MyPin = value; }
        }
        public Account(int i_AccountNumber, string i_FullName, int i_CardLimit, int i_Balance, string i_Id)
        {
            m_AccountNumber = i_AccountNumber;
            m_AccountName = i_FullName;
            MyPin = i_Id;
            m_CardLimit = i_CardLimit;
            MyBalance = i_Balance;
        }

        public bool MoneyWithdraw(int i_WithdrawAmount)
        {


            if (i_WithdrawAmount < this.MyBalance && i_WithdrawAmount > 0)
            {
                this.MyBalance -= i_WithdrawAmount;
                return true;
            }
            return false;


        }

        public bool MoneyDeposit(int i_DepositAmount)
        {
            if (i_DepositAmount > 0)
            {
                this.MyBalance += i_DepositAmount;
                return true;
            }
            return false;
        }

        public int BalanceCheck()
        {
            return this.MyBalance;
        }

        public string AccountDetails()
        {
            string i_MyAccountdetails;
            i_MyAccountdetails = "Account Name : " + m_AccountName + " Account holder Id : " + MyPin + " Account Number : " + m_AccountNumber + " Account balance : " + MyBalance + " Usd Credit card limit : " + m_CardLimit+" Usd";
            return i_MyAccountdetails;
        }


    }
}
///////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtmClassLibrary
{
    public class Bank
    {
        private CardsAndCodes[] m_CardAndCodesList;
        private Account[] m_AccountList;
        private CreditCard[] m_CreditCardList;
      
        private struct CardsAndCodes
        {
            public int CardNumber;
            public int CardCode;

            public CardsAndCodes(int i_CardNumber, int i_CardCode)
            {
                CardNumber = i_CardNumber;
                CardCode = i_CardCode;
            }

        }
        //test code
        public Bank()
        {
            m_CardAndCodesList = new CardsAndCodes[1];
            m_CardAndCodesList[0].CardCode = 1234;
            m_CardAndCodesList[0].CardNumber = 1234;
            m_AccountList = new Account [1];
            m_AccountList[0]=new Account(1234, "david", 1000, 10000, "011406");
            m_CreditCardList = new CreditCard[1];
            m_CreditCardList[0] = new CreditCard(e_CardType.CardType.mastercard, DateTime.Today, "david", 1234, 1000, 1234);
        }
        //test code

        public bool CreditCardCheck(int i_CardNumber, int i_CardCode)
        {
            foreach (CardsAndCodes EachCard in m_CardAndCodesList)
            {
                if (i_CardNumber == EachCard.CardNumber && i_CardCode == EachCard.CardCode)
                {
                    return true;
                }
            }
            return false;
        }
        public CreditCard GetCreditCard(int i_CardNumber)
        {
            foreach (CreditCard MyCreditCard in m_CreditCardList)
            {
                if (i_CardNumber == MyCreditCard.CardNumber)
                {
                    return MyCreditCard;
                }
            }
            return null;
        }
        public Account GetBankAccount(int i_AccountNumber)
        {
            foreach (Account MyAccount in m_AccountList)
            {
                if (i_AccountNumber == MyAccount.AccountNumber)
                {
                    return MyAccount;
                }
            }
            return null;
          
        }
    }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote