Convert to C# Language def Deposit(balance, pin):                            # Deposit function     p = int(input("Enter the PIN: "))                 # taking PIN from user     if p == pin:                                # if PIN matches with actual PIN         amount = float(input("Enter deposit amount: "))    # taking deposit amount from user         balance += amount                                 # adding deposit amount to balance     else:                                       # else  (if PIN not matches)         print("Incorrect PIN!!")                # display message     return balance                        # return balance

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter5: Repetition Statements
Section: Chapter Questions
Problem 7PP
icon
Related questions
Question

Convert to C# Language

def Deposit(balance, pin):                            # Deposit function
    p = int(input("Enter the PIN: "))                 # taking PIN from user
    if p == pin:                                # if PIN matches with actual PIN
        amount = float(input("Enter deposit amount: "))    # taking deposit amount from user
        balance += amount                                 # adding deposit amount to balance
    else:                                       # else  (if PIN not matches)
        print("Incorrect PIN!!")                # display message
    return balance                        # return balance



def Withdraw(balance, pin):                     # Withdraw function
    p = int(input("Enter the PIN: "))            # taking PIN from user
    if p == pin:                                 # if PIN matches with actual PIN
        amount = float(input("Enter withdraw amount: "))       # taking withdrawal amount from user
        if amount > balance:                                 # if withdraw amount > balance
            print("Insufficient Balance")                    # print insufficient balance
        else:                                       # else (if withdraw amount <= balance)
            balance -= amount                     # subtracting deposit amount from balance
    else:                                        # else  (if PIN not matches)
        print("Incorrect PIN!!")                 # display message
    return balance                          # return balance



def Inquire(balance, pin):                     # Inquire function
    p = int(input("Enter the PIN: "))             # taking PIN from user
    if p == pin:                                 # if PIN matches with actual PIN
        print("The outstanding balance is =", balance)            # display the outstanding balance
    else:                                       # else  (if PIN not matches)
        print("Incorrect PIN!!")               # display message



# main program

 

# taking initial amount from user
initial_amount = float(input("Enter an outstanding balance as initial amount: "))
while True:                                                # infinite while loop
    pin = int(input("Enter a 4 digit PIN: "))             # taking PIN from user for the first time
    if len(str(pin)) != 4:                                # if PIN is not 4 digit
        print("Invalid PIN!! PIN must be of 4 digit.")    # display message
    else:                                                  # else (if PIN is of 4 digit)
        break                                            # break the infinite while loop

 

print("1. Deposit\n2. Withdraw\n3. Inquire\n4. Exit")     # display statement
while True:                                              # infinite while loop
    ch = int(input("Enter your choice (1-4): "))         # taking choice from user
    if ch == 1:                                           # if ch = 1
        initial_amount = Deposit(initial_amount, pin)     # calling Deposit function
    elif ch == 2:                                         # if ch = 2
        initial_amount = Withdraw(initial_amount, pin)     # calling Withdraw function
    elif ch == 3:                                         # if ch = 3
        Inquire(initial_amount, pin)                       # calling Inquire function
    elif ch == 4:                                        # if ch = 4
        print("Exiting...")                               # print exit message
        break                                            # break the infinite while loop
    else:                                                # else (choice other than 1/2/3/4)
        print("Invalid Choice!!")                        # display message
Expert Solution
steps

Step by step

Solved in 4 steps

Blurred answer
Knowledge Booster
ADT and Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage