I am in the early stages of working with programing. Everyone I talk to around here who is in programing knows how to do the hard stuff but everyone of them said they did not have to start off using basic.
I am trying to make that numbers game. I can get it to loop however I can not get it to stop the loop and it wants to keep going. I have posted the code below. If someone can help me please let me know. thank you
'Declare subs
declare sub begin
declare sub gameover
declare sub display
declare sub win
declare sub compute
'Declare Variables
DIM shared secretnum AS single
dim shared yournumber as single
dim shared counter as single
dim shared difference as single
dim shared range1 as single =300
dim shared range2 as single =200
dim shared range3 as single =100
dim shared range4 as single =50
dim shared range5 as single =10
dim shared range6 as single =1
'Main Program
'Seeds the random function otherwise you will always get
'the same number
RANDOMIZE TIMER
secretnum = INT(1000 * RND + 1)
counter= 1
do until yournumber = secretnum and counter <=7
counter=counter+1
compute
display
gameover
loop
win
sleep
end
sub gameover
if counter >7 then
beep
beep
beep
Print "You had your seven guesses."
Print "The secret number was"; secretnum
Print "More than 7 guesses you lose!"
Print "Thank you for playing"
end if
end sub
sub compute
'user enters a number
Input "Enter a number between 1 and 1000"; yournumber
'computer computes difference
difference = yournumber - secretnum
difference = abs (difference)
end sub
sub display
'computer dispalys info according to guess
If difference >range1 then
Print "Freezing cold. Off by more than 300"
ELSE
IF difference>range2 then
Print "Cold. Off by 200-300"
ELSE
IF difference >range3 then
Print "Cool. Off by 100-199"
ELSE
IF difference >range4 THEN
PRINT "Warm. Off by 50-99"
ELSE
IF difference > range5 THEN
Print "Hot! Off by 10-49"
ELSE
IF difference > range6 THEN
PRINT "On Fire! Off by 1-9"
end if
end if
end if
end if
end if
end if
end sub
sub win
IF yournumber = secretnum then
Print "*********************************"
Print "********** You guessed **********"
Print "*********************************"
Print "*Your number is the secret number*"
Print "*********************************"
Print "****You Win! Congratulations*****"
Print "*********************************"
End if
end sub