Posted: Thu May 13, 2004 10:51 pm Post subject: checking input
when i type in the wrong one it comes out the first time it shows "incorrect input", but when i type a right input in it afterwards it still shows the "incorrect input". but if the first time i type in the right input it shows "correct"
code:
loop
itries := itries + 1
for count : 1 .. 5
getch (sinput)
put "!"..
inum := strint (sinput)
if count = 1 then
inum := inum * 10000
elsif count = 2 then
inum := inum * 1000
elsif count = 3 then
inum := inum * 100
elsif count = 4 then
inum := inum * 10
else
inum := inum
end if
iguess:=iguess+inum
end for
if (iguess div 1000) + (iguess mod 1000) = 368 then
put "correct"
scheck := "g"
else
put " Incorrect input."
end if
exit when itries = 3 or scheck = "g"
end loop
Sponsor Sponsor
zeldamaster1230
Posted: Fri May 14, 2004 7:49 am Post subject: (No subject)
I believe that what your problem is is not re-declaring iguess each time you run through the loop. Therefore, what would happen is that iguess would keep increasing, and, after the first run-through, never reach your destination again. Hope that helps.