
-----------------------------------
a random person
Fri Nov 25, 2005 5:53 pm

can somone edit these
-----------------------------------
i have a couple of eronious programs and i need somone to help

%flashcards
var a, b, u, x, t : int
x = 0
for t : 1 .. 10
    put t
    delay (100)
    cls
    loop
        randint (a, 1, 9)
        randint (b, 1, 9)
        put a, "+", b
        get u
        if a + b < u then
            put "game over, your score is ", x
        elsif a + b > u then
            put "game over, your score is ", x
        else
            x := x + 1
            exit when a + b < u or a + b > u
        end if
    end loop
end for
if t = 10 then
    put "you ran out of time, your score is", x
else
end if


there is another one aswell

var minute, hour : int
minute := 0
hour := 0
for second : 1 .. 60000
    put hour,":",minute,":",second
    delay (1000)
    cls
    if second = 60 then
        put minute + 1, ":", second - 60
    else
    end if
    if minute = 60 then
        put hour + 1, ":" ,minute - 60
    else
    end if
end for

if some one can help me i will be great!

-----------------------------------
md
Fri Nov 25, 2005 7:07 pm


-----------------------------------
you need to ask a question to get any help ;)

-----------------------------------
a random person
Sat Nov 26, 2005 8:44 am


-----------------------------------
sry about that, first post and all  :oops: . the first one is a flash cards
program where they have 1 second to respond with the answer and the
other one is just a count up clock. with both of these I ran into some
logic problems that i can't work around  :(  so, can anyone help me?

-----------------------------------
a random person
Sat Nov 26, 2005 1:45 pm


-----------------------------------
guess what i have another one if anyone can curve this line it would be amasing

var x,y:int
x:=maxx div 2
y:=0
for i :1..319
x:=x-1
y:=y+1
drawdot (x,y,12)
delay (20)
end for
if x=0 then
x:=x-1
else
end if


-----------------------------------
[Gandalf]
Sat Nov 26, 2005 2:10 pm


-----------------------------------
Take a look at all the changes I have made in the last program, and see if you understand them.

var x : int
var y, iy : real
x := maxx div 2
y := 0
iy := +0.1
for i : 1 .. 319
    x -= 1
    y += iy
    iy += 0.005
    Draw.Dot (x, round (y), 12)
    Time.DelaySinceLast (20)
end for
1. iy is how much the y coordinate increases every iteration of the loop, that value increase after it is added to y.  This causes the curve.
2. you must round y when you are passing it to Draw.Dot() (drawdot()), because that procedure needs an integer, not a decimal number.
3. x -= 1 is the same thing as x := x - 1
4. use Time.DelaySinceLast() instead of delay(), since it works the same on all computers.
5. Please indent your program, at least use "F2".

As for your other programs, they seem to have logic errors in them, think them through and you should get the right answer.  Thing step by step, try to follow what the program does.

-----------------------------------
[Gandalf]
Sat Nov 26, 2005 7:38 pm


-----------------------------------
Yes, yes, please put replys in the topic which you posted in originally.

and has a poor subject name.
I don't know about a poor subject name though ;).

Well, think about it, for that program you have it so that if second = 60 then... do whatever needed for when the seconds are over a minute.  The thing is, what happens when there are 61 seconds?  It goes back since second > 60, you need to take that into consideration.  Solve that problem on your own, and try to figure out what is wrong with the other program as well.  I, or anyone else, won't give you the exact answers, we can only help occasionally.[/quote]

-----------------------------------
milz
Sun Nov 27, 2005 11:38 am


-----------------------------------
Yo here is ur correct code. hav fun..

 :( 
%flashcards 
var a, b, u, x : int 
x := 0 
for t : 1 .. 10 
    put t 
    delay (100) 
    cls 
    loop 
        randint (a, 1, 9) 
        randint (b, 1, 9) 
        put a, "+", b 
        get u 
        if a + b < u then 
            put "game over, your score is ", x 
        elsif a + b > u then 
            put "game over, your score is ", x 
        else 
            x := x + 1 
            exit when a + b < u or a + b > u 
        end if 
    end loop 
end for 
if b = 10 then 
    put "you ran out of time, your score is", x 
else 
end if
