Computer Science Canada

I need help with this program, i cant figure this out.

Author:  solblade05 [ Tue Jan 03, 2006 12:00 pm ]
Post subject:  I need help with this program, i cant figure this out.

the division section isn't working...
I only want even numbers to appear, but I don't know how to do it. i also need the larger number to come first. I tried everything but I can't figure it out PLEASE help me.

Also if there is anyway to make this program code shorter, I could really appreciate that. Also i need to make the program compatible with elementary children, so i need something so when there is animation, the user can still click...

Thanks

Author:  solblade05 [ Tue Jan 03, 2006 12:01 pm ]
Post subject: 

sorry for the double download...

Author:  pavol [ Tue Jan 03, 2006 12:21 pm ]
Post subject: 

for the part where you only want even numbers to come up, i know there is a more efficient way, i've done it before, but this is the simple way i suppose. just put the randomizing in a loop and don't let it exit unless an even number has been generated.
code:
loop
    randint (a, 2, 10)

    exit when a = 2 or a = 4 or a = 6 or a = 8 or a = 10
end loop

loop
    randint (b, 2, 10)
   
    exit when b = 2 or b = 4 or b = 6 or b = 8 or b = 10
end loop


and for the larger number to appear first doesn't your code work? i think it should
code:
if b > a then
    temp := b
    b := a
    a := temp
end if

Author:  solblade05 [ Tue Jan 03, 2006 12:31 pm ]
Post subject: 

I know what you mean but thats not what i wanted..
it somthing like this :
i want the 2 random #s to multiply, then display the product and a/b
the question will be some thing like this

product (of a and b) divided by a/b, the answer will be a/b dependin on what i choose to display ^^ here

Author:  pavol [ Tue Jan 03, 2006 1:00 pm ]
Post subject: 

im not sure i understand when i take a look at your program it looks like a normal quiz. you randomize two numbers and either +, -, *, or / them. and you get an answer.

Author:  solblade05 [ Tue Jan 03, 2006 1:07 pm ]
Post subject: 

i'm a newb, remember that, how do i multiply 2 random numbers?
and display the the product of the numbers

Author:  DIIST [ Tue Jan 03, 2006 1:31 pm ]
Post subject: 

solblade05 wrote:
i'm a newb, remember that, how do i multiply 2 random numbers?
and display the the product of the numbers


code:

var num1, num2 : int

randint (num1, 1, 50) %randint(varible(int),minvalue,maxvalue)
randint (num2, 1, 50)

%Out puts the product
put num1, " X ", num2, " = ", num1 * num2


Author:  pavol [ Tue Jan 03, 2006 1:36 pm ]
Post subject: 

i didn't understand why you asked because you've already done that in your program Confused

Author:  solblade05 [ Tue Jan 03, 2006 2:14 pm ]
Post subject: 

Almost like Thuvs code but i need to do that in font.draw.

i know that i have to use intstr.
like this

Font.Draw (intstr (a) + " / " + intstr (b) + " = ", 90, 565, f14, black)

Author:  solblade05 [ Tue Jan 03, 2006 2:57 pm ]
Post subject: 

Its OK i Got It!!! Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Laughing Laughing Surprised Surprised


: