Exercise
Password V2
Objetive
Write a Visual Basic (VB.Net) program to ask the user for their login and password (both must be integer numbers) until the entered login is "12" and the password is "1234". The user will have a maximum of three attempts.
Code
Imports System
Public Class Program
Public Shared Sub Main()
Dim login As Integer
Dim password As Integer
Dim attempts As Integer = 0
While attempts < 3
Console.WriteLine("Enter login:")
login = Convert.ToInt32(Console.ReadLine())
Console.WriteLine("Enter password:")
password = Convert.ToInt32(Console.ReadLine())
If login = 12 AndAlso password = 1234 Then
Console.WriteLine("Access granted.")
Return
Else
attempts += 1
Console.WriteLine("Invalid login or password. Try again.")
End If
End While
Console.WriteLine("Maximum attempts reached. Access denied.")
End Sub
End Class