How to resolve the algorithm Guess the number/With feedback step by step in the VBScript programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Guess the number/With feedback step by step in the VBScript programming language

Table of Contents

Problem Statement

Write a game (computer program) that follows the following rules:

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Guess the number/With feedback step by step in the VBScript programming language

Source code in the vbscript programming language

Dim max,min,secretnum,numtries,usernum
max=100
min=1
numtries=0
Randomize
secretnum = Int((max-min+1)*Rnd+min)

Do While usernum <> secretnum
  usernum = Inputbox("Guess the secret number beween 1-100","Guessing Game")
  If IsEmpty(usernum) Then
    WScript.Quit
  End If
  If IsNumeric(usernum) Then
    numtries = numtries + 1
    usernum = Cint(usernum)
    If usernum < secretnum Then
      Msgbox("The secret number is higher than " + CStr(usernum))
    ElseIf usernum > secretnum Then
      Msgbox("The secret number is lower than " + CStr(usernum))
    Else
      Msgbox("Congratulations, you found the secret number in " + CStr(numtries) + " guesses!")
    End If
  Else
    Msgbox("Please enter a valid number.")
  End If
Loop

  

You may also check:How to resolve the algorithm Isqrt (integer square root) of X step by step in the Raku programming language
You may also check:How to resolve the algorithm Checkpoint synchronization step by step in the J programming language
You may also check:How to resolve the algorithm String matching step by step in the Fantom programming language
You may also check:How to resolve the algorithm Continued fraction/Arithmetic/G(matrix ng, continued fraction n1, continued fraction n2) step by step in the Owl Lisp programming language
You may also check:How to resolve the algorithm Cramer's rule step by step in the Lua programming language