8. create a console application. Insert the below code, and run the program. Note that a conditional statement is used within the body of the loop. This is common. Write a similar program using this one as an example that asks the user to name his or her favorite make of automobile. If the user fails to guess, provide feedback that includes a hint, e.g. “Hint: This make of your car is made in Germany”.

Module Module1

    Sub Main()
        Dim BMW As String
        Dim guess As String = ""
        Do Until guess = BMW
            Console.WriteLine("Name your favorite make of automobile")
            guess = Console.ReadLine()
            If guess != BMW Then
                Console.WriteLine("Sorry wrong answer hint: This make of car is made in Germany.")
                Console.WriteLine()
            End If
        Loop
        Console.WriteLine("Congratulations you guessed the right automobile!")
        Console.WriteLine()
        Console.WriteLine("Press [Enter] key to continue")
        Console.ReadLine()

    End Sub

End Module

error
identifier expected If guess != BMW Then
^

Recommended Answers

All 3 Replies

try this:

Dim guess As String = ""
		Do Until guess = "BMW"
			Console.WriteLine("Name your favorite make of automobile")
			guess = Console.ReadLine()
			If guess <> "BMW" Then
				Console.WriteLine("Sorry wrong answer hint: This make of car is made in Germany.")
				Console.WriteLine()
			End If
		Loop

thanks sknake that worked wonderfully i thought about using the <>

You're welcome and i'm glad you got it working.

Please mark this thread as solved if you have found a solution to your question and good luck!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.