Answer to Question #278618 in Visual Basic for Gwen

Question #278618

Using conditional statements design a login where a user will enter a username and password


A) on successful login a welcome message is displayed


B) on 3 attempts an invalid message is displayed informing the user of the attempts remaining


C)on the fourth unsuccessful attempt the program will exit and inform the user of failed attempts

1
Expert's answer
2021-12-12T01:17:49-0500
Imports System.IO


Module Module1
    Sub Main()
        Dim attempts As Integer = 0
        While attempts < 4
            Console.Write("Enter username: ")
            Dim username As String = Console.ReadLine()
            Console.Write("Enter password: ")
            Dim password As String = Console.ReadLine()
            If username = "admin" And password = "1111" Then
                Console.WriteLine("You're Welcome")
                attempts = 5
            Else
                attempts += 1
                Console.WriteLine("Wrong username or password.")
            End If
            If attempts = 3 Then
                Console.WriteLine("Wrong username or password. 1 attempts remaining")
            End If
        End While


        If attempts <> 5 Then
            Console.WriteLine("4 failed attempts")
        End If












        Console.ReadLine()
    End Sub




End Module

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