Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Game code for Jenny

Imports System

Public Class Test
    Public Shared Sub Main()
        Dim randomNum as Integer, a as Integer = 0, b as Integer = 0, i as Integer
        Dim random as System.Random = new System.Random()
        Dim guess as String
        
        randomNum = 1222 'random.Next(1000, 9999)
        
        guess = Console.ReadLine()
        
        for i = 0 to 3
            a = a + If(guess.Chars(i).Equals(randomNum.ToString().Chars(i)), 1, 0)
            b = b + If(Not guess.Chars(i).Equals(randomNum.ToString().Chars(i)) And randomNum.ToString().IndexOf(guess.Chars(i)) > -1, 1, 0)
        next
        
        Console.WriteLine(guess)
        Console.WriteLine(randomNum)
        Console.WriteLine(a & "A")
        Console.WriteLine(b & "B")
    End Sub
End Class

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.