Jump to content



Photo
- - - - -

Casio Cfx 9850gc Plus Quiz Program


  • Please log in to reply
4 replies to this topic

#1 Max

Max

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 03 October 2006 - 04:31 PM

Hi everyone , i just got my CFX 9850GC and started to programm some simple things :)

I want a program thats ask a question , and then you push 1 for Yes 2 for No
But i can only make one answer

My code for exampel:

"Do you like cookies"?->A
If A=1
Then "Okey so you do like cookies"
If A=2
Then "Okey you hate cookies"

I can only pick "1" , if i pick "2" it dosent work. :banghead:

Can somebody tell me what im doing wrong , thank you

#2 ndzamana

ndzamana

    Newbie

  • Members
  • Pip
  • 13 posts
  • Gender:Male
  • Location:Poland

  • Calculators:
    ClassPad 300, fx-9860G SD, Algebra FX 2.0 Plus, CFX-9850G PLUS

Posted 03 October 2006 - 06:18 PM

Hi
If I were you I would write this like that:

If A=1
Then "Okey so you do like cookies"
IfEnd
If A=2
Then "Okey you hate cookies"
IfEnd

or

If A=1
Then "Okey so you do like cookies"
Else If A=2
Then "Okey you hate cookies"
IfEnd
IfEnd

or

If A=1
Then "Okey so you do like cookies"
Else "Okey you hate cookies"
IfEnd

It should work!

#3 Max

Max

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 03 October 2006 - 08:33 PM

Thanks mate :)

If i now want the numbers to be letters instead

1= Yes
2= No

Code ATM:

"Do you like cookies"?->A
If A=Yes
Then "Okey so you do like cookies"
IfEnd
If A=No
Then "Okey you hate cookies"
IfEnd

Why dosent that work?
It just gives me all answers when i type any letter , it can be q , b , c and so on.

// Max

#4 kucalc

kucalc

    Casio Maniac

  • [Legends]
  • PipPipPipPipPipPipPipPip
  • 1422 posts
  • Gender:Male
  • Location:USA
  • Interests:Programming: C/C++, Fortran, LISP, COBOL 85 Standard, PHP, x86 and SH3 Assembly

    Computer graphics

  • Calculators:
    fx-9860G / fx-7400G Plus / Algebra FX 2.0+ / fx-9770G / CFX-9850G / CFX-9850GB+ / TI-89 / TI-nSpire

Posted 03 October 2006 - 11:06 PM

Why dosent that work?
It just gives me all answers when i type any letter , it can be q , b , c and so on.

// Max


That's because the CFX sees "Yes" and "No" as variables, not characters. So your "Yes" would be Y x e x s, multiplication, and "No" as N x o (multiplied). :lol:

#5 alias4399

alias4399

    Casio Freak

  • Members
  • PipPipPipPip
  • 180 posts
  • Location:Impossible to say.. Its not like this is a constant!

  • Calculators:
    CFX 9850GB Plus
    FX 9860G

Posted 04 October 2006 - 04:50 AM

If you are only using 1 line conditions, you don't need 'If' statements.
Like so:
A=1=>"So you do like cookies."
A=2=>"So you don't like cookies."
If you really want the user to type in 'Yes' and 'No' even though it is easier to use 'Y' and 'N', there is a way you can do it:
lets say you assign the variables A~Z with the values 1-26.
Now, YES = 25 x 5 x 19.
You could do the same thing with 'Y' and 'N', however for the most fluidity, you could test for keypresses and not 'typed in input'.
Eg:
While G=/=32 And G=/=64
Do:Getkey->G
LpWhile G=0
G=32=>"So you do like cookies."	 // 32 is the keycode for Y
G=64=>"So you don't like cookies." // 64 is the keycode for N
WhileEnd
In the above example, as soon as the user presses Y or N the program will react. This is useful for action games. The first while statement is to make sure the user pressed either Y or N, if they didn't, it will start the whole loop again. If anything puzzles you, ask about it.

Note: If you don't know which keycodes you need, either find a key listing online or make a new program with this code:
While 1
Locate 1,1,Getkey
For 1->A To 50   // pause for a bit
Next
WhileEnd
Now, when you run the program, just tap the key you want the keycode of and it will display it!


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users