Jump to content



Photo
- - - - -

How To Enter More Than Three If Statements

If Then Statements multiple if help programming speech

  • Please log in to reply
8 replies to this topic

#1 Dameyan1212

Dameyan1212

    Newbie

  • Members
  • Pip
  • 4 posts

  • Calculators:
    fx-9860GII

Posted 14 September 2012 - 09:09 PM

So ive been trying to enter more than 3 if statements. Its just a fun type thing. I want to be able to have my friends be able to input their and there be a response to each of their names. I have managed to have 2 peoples names in. But when i try to add a third name in, the same way i added in the second name it doesnt work. Example of the the 2 names working is...
"WHATS YOUR NAME"?->A
If	 A=STEPH
Then	 "HEY STEPH"
IfEnd
If	 A=TYLER
Then	 "HEY TYLER"
Else	 "NAME IS NOT REGISTERED"
Now when i attempt to add a third name like this...
"WHATS YOUR NAME"?->A
If	 A=STEPHANIE
Then	 "HEY STEPH"
IfEnd
If	 A=TYLER
Then	 "HEY TYLER"
IfEnd
If	 A=DYLAN
Then	 "HEY DYLAN"
Else	 "NAME IS NOT REGISTERED"
IfEnd
When i do this the first name input, in this case "STEPHANIE", works without a problem and it displays, "HEY STEPH.
But if i input "TYLER" or "DYLAN" it displays

"HEY TYLER"
"HEY DYLAN"

And ive tried adding more names and responses like this
"WHATS YOUR NAME"?->A
If	 A=STEPHANIE
Then	 "HEY STEPH"
IfEnd
If	 A=TYLER
Then	 "HEY TYLER"
IfEnd
If	 A=DYLAN
Then	 "HEY DYLAN"
IfEnd
If	 A=CHRISTIAN
Then	 "HEY CHRISTIAN"
IfEnd
If	 A=JESSICA
Then	 "HEY JESSICA"
Else	 "NAME IS NOT REGISTERED"
IfEnd

But as before the Stepahnie's response works perfect but if i enter any other name i get all responses in sequence except Stephanie's like this

"HEY TYLER"
"HEY DYLAN"
"HEY CHRISTIAN"
"HEY JESSICA"

No matter which name (other than STEPHANIE) i put in, I get that result.
Please Help. Im toying with it to try to figure it out. If you know my error, please comment and point it out.
Thank you all in advanced! :greengrin: :rolleyes: :greengrin: :rolleyes: :greengrin:

Edited by Dameyan1212, 14 September 2012 - 09:12 PM.


#2 flyingfisch

flyingfisch

    Casio Maniac

  • Deputy
  • PipPipPipPipPipPipPipPip
  • 1891 posts
  • Gender:Male
  • Location:OH,USA
  • Interests:Aviation, Skiing, Programming, Mountain Biking.

  • Calculators:
    fx-9860GII
    fx-CG10 PRIZM

Posted 14 September 2012 - 09:42 PM

Hello Dameyan1212 and welcome to UCF! You should introduce yourself.

try else if. Like this:

"WHATS YOUR NAME"?->A
If	 A=STEPHANIE
Then	 "HEY STEPH"
Else If	 A=TYLER
Then	 "HEY TYLER"
Else If	 A=DYLAN
Then	 "HEY DYLAN"
Else If	 A=CHRISTIAN
Then	 "HEY CHRISTIAN"
Else If	 A=JESSICA
Then	 "HEY JESSICA"
Else	 "NAME IS NOT REGISTERED"
IfEnd


EDIT:

Actually, what I just said won't work either. The real problem doesnt have anything to do with If statements. We need to use strings, that's all. ;)

So like this:

"NAME" -> Str 1

If strcmp(str 1, "STEPHANIE")
Then "HI STEPHANIE"
IfEnd

...

The reason the other code did not work was because since you were not using strings, it was handleing each letter a a number variable.

  • Dameyan1212 likes this

#3 Dameyan1212

Dameyan1212

    Newbie

  • Members
  • Pip
  • 4 posts

  • Calculators:
    fx-9860GII

Posted 20 September 2012 - 11:27 PM

Thank you. Ive never used stings but I'll figure it out. Im assuming for te next person i put "NAME" -> Str 2?

#4 Dameyan1212

Dameyan1212

    Newbie

  • Members
  • Pip
  • 4 posts

  • Calculators:
    fx-9860GII

Posted 21 September 2012 - 12:15 AM

I have no clue how to use stings...

#5 Forty-Two

Forty-Two

    Casio Overlord

  • Deputy
  • PipPipPipPipPipPipPip
  • 528 posts
  • Gender:Male
  • Location:Well, The sign says "You are here"...

  • Calculators:
    Casio fx-CG10 Prizm
    Casio fx-9860GII
    TI-84+ SE

Posted 21 September 2012 - 02:41 AM

I have no clue how to use stings...


Making sure your calc is in linear mode first (In run-mat, shift->menu; f2). When you need to insert a string, type Var, F6, F5 followed by the string you want to reference. To access the string commands, press shift->vars, f6, f6, f1.

#6 flyingfisch

flyingfisch

    Casio Maniac

  • Deputy
  • PipPipPipPipPipPipPipPip
  • 1891 posts
  • Gender:Male
  • Location:OH,USA
  • Interests:Aviation, Skiing, Programming, Mountain Biking.

  • Calculators:
    fx-9860GII
    fx-CG10 PRIZM

Posted 21 September 2012 - 06:39 PM

Making sure your calc is in linear mode first (In run-mat, shift->menu; f2).

PRGM mode is always linear, but anyway... ;)


Thank you. Ive never used stings but I'll figure it out. Im assuming for te next person i put "NAME" -> Str 2?


Yeah, like this:
"NAME" -> Str 1

If strcmp(str 1, "STEPHANIE")
Then "HI STEPHANIE"

Else If strcmp(str 1, "NAME")
Then "HI NAME"

Else "NAME NOT REGISTERED"
IfEnd

BTW, to access strcmp(), go to the string (str) section of the program menu.

Usage:

strcmp(<string>,<string>)

It compares the two strings. If they are the same, it returns 1 (true). Otherwise, it returns 0 (false).

#7 Dameyan1212

Dameyan1212

    Newbie

  • Members
  • Pip
  • 4 posts

  • Calculators:
    fx-9860GII

Posted 23 September 2012 - 12:28 AM

Ok i think i get it. im gonna go try. if not ill be back. But thanks

#8 flyingfisch

flyingfisch

    Casio Maniac

  • Deputy
  • PipPipPipPipPipPipPipPip
  • 1891 posts
  • Gender:Male
  • Location:OH,USA
  • Interests:Aviation, Skiing, Programming, Mountain Biking.

  • Calculators:
    fx-9860GII
    fx-CG10 PRIZM

Posted 23 September 2012 - 04:31 PM

OK, cool. Feel free to post here again if you have more trouble with this program.

I look forward to seeing your future programs :)

#9 somebody1234

somebody1234

    Casio Addict

  • Members
  • PipPipPip
  • 51 posts

  • Calculators:
    Casio fxcg10
    Casio fx-9860GII
    Casio Classpad 400

Posted 08 February 2014 - 12:02 AM

I think you can make the program respond to any name.
This is my code:
"What is your name"?->Str 1
"Hi"
Locate 7,3,Str 1
Locate StrLen(Str 1)+7, 3, "."
My code uses all caps for the text so it looks the same as your response.



Also tagged with one or more of these keywords: If, Then, Statements, multiple if, help, programming, speech

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users