Problem #50
  
  
  
  
  
  
  
  
  
    
    
      
Code Overview
1. Header Files and Namespace:
- <iostream>is included for input and output operations.
- using namespace std;allows the use of standard functions without prefixing them with- std::.
2. User Input Function (ReadPinCode)
- Prompts the user to enter a PIN code.
- Reads and returns the entered PIN code.
3. Authentication Function (Login)
- Uses a do-while loop to allow a maximum of 3 attempts.
- If the correct PIN (1234) is entered, it returnstrue(successful login).
- If the wrong PIN is entered:- The remaining attempts are displayed.
- The user can retry up to 3 times.
 
- If the user fails all 3 attempts, it returns false(access blocked).
4. Program Execution (main())
- Calls Login()to authenticate the user.
- If login is successful:- Changes console text to green (system("color 2F")for Windows).
- Displays the account balance (7500).
 
- If login fails after 3 attempts:- Changes console text to red (system("color 4F")for Windows).
- Displays a message indicating that the card is blocked.
 
- Returns 0to indicate successful execution.
 
    
   
Complete and Continue
 
  
  
    
  
 
    
    
    
   
22 comments