Making program, so that I can input word and output coded word.

Does not work
Help Please


Code:
"θ"→Str0
"θ"→Str1
"θ"→Str2
"θ"→Str3
"θ"→Str4
"θ"→Str5
"θ"→Str6
"θ"→Str7
"θ"→Str8
"θ"→Str9
Prompt Str1
Prompt Str2
If Str2≠"θ"
Then
Prompt Str3
If Str3≠"θ"
Then
Prompt Str4
If Str4≠"θ"
Then
Prompt Str5
If Str5≠"θ"
Then
Prompt Str6
If Str6≠"θ"
Then
Prompt Str7
If Str7≠"θ"
Then
Prompt Str8
End
End
End
End
End
End

If Str1="A"
Then
"N"→Str1
End
If Str1="B"
Then
"O"→Str1
End
If Str1="C"
Then
"P"→Str1
End
If Str1="D"
Then
"Q"→Str1
End
If Str1="E"
Then
"R"→Str1
End
If Str1="F"
Then
"S"→Str1
End
If Str1="G"
Then
"T"→Str1
End
If Str1="H"
Then
"U"→Str1
End
If Str1="I"
Then
"V"→Str1
End
If Str1="J"
Then
"W"→Str1
End
If Str1="K"
Then
"X"→Str1
End
If Str1="L"
Then
"Y"→Str1
End
If Str1="M"
Then
"Z"→Str1
End
If Str1="N"
Then
"A"→Str1
End
If Str1="O"
Then
"B"→Str1
End
If Str1="P"
Then
"C"→Str1
End
If Str1="Q"
Then
"D"→Str1
End
If Str1="R"
Then
"E"→Str1
End
If Str1="S"
Then
"F"→Str1
End
If Str1="T"
Then
"G"→Str1
End
If Str1="U"
Then
"H"→Str1
End
If Str1="V"
Then
"I"→Str1
End
If Str1="W"
Then
"J"→Str1
End
If Str1="X"
Then
"K"→Str1
End
If Str1="Y"
Then
"L"→Str1
End
If Str1="Z"
Then
"M"→Str1
End

If Str2="A"
Then
"N"→Str2
End
If Str2="B"
Then
"O"→Str2
End
If Str2="C"
Then
"P"→Str2
End
If Str2="D"
Then
"Q"→Str2
End
If Str2="E"
Then
"R"→Str2
End
If Str2="F"
Then
"S"→Str2
End
If Str2="G"
Then
"T"→Str2
End
If Str2="H"
Then
"U"→Str2
End
If Str2="I"
Then
"V"→Str2
End
If Str2="J"
Then
"W"→Str2
End
If Str2="K"
Then
"X"→Str2
End
If Str2="L"
Then
"Y"→Str2
End
If Str2="M"
Then
"Z"→Str2
End
If Str2="N"
Then
"A"→Str2
End
If Str2="O"
Then
"B"→Str2
End
If Str2="P"
Then
"C"→Str2
End
If Str2="Q"
Then
"D"→Str2
End
If Str2="R"
Then
"E"→Str2
End
If Str2="S"
Then
"F"→Str2
End
If Str2="T"
Then
"G"→Str2
End
If Str2="U"
Then
"H"→Str2
End
If Str2="V"
Then
"I"→Str2
End
If Str2="W"
Then
"J"→Str2
End
If Str2="X"
Then
"K"→Str2
End
If Str2="Y"
Then
"L"→Str2
End
If Str2="Z"
Then
"M"→Str2
End


If Str3="A"
Then
"N"→Str3
End
If Str3="B"
Then
"O"→Str3
End
If Str3="C"
Then
"P"→Str3
End
If Str3="D"
Then
"Q"→Str3
End
If Str3="E"
Then
"R"→Str3
End
If Str3="F"
Then
"S"→Str3
End
If Str3="G"
Then
"T"→Str3
End
If Str3="H"
Then
"U"→Str3
End
If Str3="I"
Then
"V"→Str3
End
If Str3="J"
Then
"W"→Str3
End
If Str3="K"
Then
"X"→Str3
End
If Str3="L"
Then
"Y"→Str3
End
If Str3="M"
Then
"Z"→Str3
End
If Str3="N"
Then
"A"→Str3
End
If Str3="O"
Then
"B"→Str3
End
If Str3="P"
Then
"C"→Str3
End
If Str3="Q"
Then
"D"→Str3
End
If Str3="R"
Then
"E"→Str3
End
If Str3="S"
Then
"F"→Str3
End
If Str3="T"
Then
"G"→Str3
End
If Str3="U"
Then
"H"→Str3
End
If Str3="V"
Then
"I"→Str3
End
If Str3="W"
Then
"J"→Str3
End
If Str3="X"
Then
"K"→Str3
End
If Str3="Y"
Then
"L"→Str3
End
If Str3="Z"
Then
"M"→Str3
End


If Str4="A"
Then
"N"→Str4
End
If Str4="B"
Then
"O"→Str4
End
If Str4="C"
Then
"P"→Str4
End
If Str4="D"
Then
"Q"→Str4
End
If Str4="E"
Then
"R"→Str4
End
If Str4="F"
Then
"S"→Str4
End
If Str4="G"
Then
"T"→Str4
End
If Str4="H"
Then
"U"→Str4
End
If Str4="I"
Then
"V"→Str4
End
If Str4="J"
Then
"W"→Str4
End
If Str4="K"
Then
"X"→Str4
End
If Str4="L"
Then
"Y"→Str4
End
If Str4="M"
Then
"Z"→Str4
End
If Str4="N"
Then
"A"→Str4
End
If Str4="O"
Then
"B"→Str4
End
If Str4="P"
Then
"C"→Str4
End
If Str4="Q"
Then
"D"→Str4
End
If Str4="R"
Then
"E"→Str4
End
If Str4="S"
Then
"F"→Str4
End
If Str4="T"
Then
"G"→Str4
End
If Str4="U"
Then
"H"→Str4
End
If Str4="V"
Then
"I"→Str4
End
If Str4="W"
Then
"J"→Str4
End
If Str4="X"
Then
"K"→Str4
End
If Str4="Y"
Then
"L"→Str4
End
If Str4="Z"
Then
"M"→Str4
End


If Str5="A"
Then
"N"→Str5
End
If Str5="B"
Then
"O"→Str5
End
If Str5="C"
Then
"P"→Str5
End
If Str5="D"
Then
"Q"→Str5
End
If Str5="E"
Then
"R"→Str5
End
If Str5="F"
Then
"S"→Str5
End
If Str5="G"
Then
"T"→Str5
End
If Str5="H"
Then
"U"→Str5
End
If Str5="I"
Then
"V"→Str5
End
If Str5="J"
Then
"W"→Str5
End
If Str5="K"
Then
"X"→Str5
End
If Str5="L"
Then
"Y"→Str5
End
If Str5="M"
Then
"Z"→Str5
End
If Str5="N"
Then
"A"→Str5
End
If Str5="O"
Then
"B"→Str5
End
If Str5="P"
Then
"C"→Str5
End
If Str5="Q"
Then
"D"→Str5
End
If Str5="R"
Then
"E"→Str5
End
If Str5="S"
Then
"F"→Str5
End
If Str5="T"
Then
"G"→Str5
End
If Str5="U"
Then
"H"→Str5
End
If Str5="V"
Then
"I"→Str5
End
If Str5="W"
Then
"J"→Str5
End
If Str5="X"
Then
"K"→Str5
End
If Str5="Y"
Then
"L"→Str5
End
If Str5="Z"
Then
"M"→Str5
End



If Str6="A"
Then
"N"→Str6
End
If Str6="B"
Then
"O"→Str6
End
If Str6="C"
Then
"P"→Str6
End
If Str6="D"
Then
"Q"→Str6
End
If Str6="E"
Then
"R"→Str6
End
If Str6="F"
Then
"S"→Str6
End
If Str6="G"
Then
"T"→Str6
End
If Str6="H"
Then
"U"→Str6
End
If Str6="I"
Then
"V"→Str6
End
If Str6="J"
Then
"W"→Str6
End
If Str6="K"
Then
"X"→Str6
End
If Str6="L"
Then
"Y"→Str6
End
If Str6="M"
Then
"Z"→Str6
End
If Str6="N"
Then
"A"→Str6
End
If Str6="O"
Then
"B"→Str6
End
If Str6="P"
Then
"C"→Str6
End
If Str6="Q"
Then
"D"→Str6
End
If Str6="R"
Then
"E"→Str6
End
If Str6="S"
Then
"F"→Str6
End
If Str6="T"
Then
"G"→Str6
End
If Str6="U"
Then
"H"→Str6
End
If Str6="V"
Then
"I"→Str6
End
If Str6="W"
Then
"J"→Str6
End
If Str6="X"
Then
"K"→Str6
End
If Str6="Y"
Then
"L"→Str6
End
If Str6="Z"
Then
"M"→Str6
End



If Str7="A"
Then
"N"→Str7
End
If Str7="B"
Then
"O"→Str7
End
If Str7="C"
Then
"P"→Str7
End
If Str7="D"
Then
"Q"→Str7
End
If Str7="E"
Then
"R"→Str7
End
If Str7="F"
Then
"S"→Str7
End
If Str7="G"
Then
"T"→Str7
End
If Str7="H"
Then
"U"→Str7
End
If Str7="I"
Then
"V"→Str7
End
If Str7="J"
Then
"W"→Str7
End
If Str7="K"
Then
"X"→Str7
End
If Str7="L"
Then
"Y"→Str7
End
If Str7="M"
Then
"Z"→Str7
End
If Str7="N"
Then
"A"→Str7
End
If Str7="O"
Then
"B"→Str7
End
If Str7="P"
Then
"C"→Str7
End
If Str7="Q"
Then
"D"→Str7
End
If Str7="R"
Then
"E"→Str7
End
If Str7="S"
Then
"F"→Str7
End
If Str7="T"
Then
"G"→Str7
End
If Str7="U"
Then
"H"→Str7
End
If Str7="V"
Then
"I"→Str7
End
If Str7="W"
Then
"J"→Str7
End
If Str7="X"
Then
"K"→Str7
End
If Str7="Y"
Then
"L"→Str7
End
If Str7="Z"
Then
"M"→Str7
End



If Str8="A"
Then
"N"→Str8
End
If Str8="B"
Then
"O"→Str8
End
If Str8="C"
Then
"P"→Str8
End
If Str8="D"
Then
"Q"→Str8
End
If Str8="E"
Then
"R"→Str8
End
If Str8="F"
Then
"S"→Str8
End
If Str8="G"
Then
"T"→Str8
End
If Str8="H"
Then
"U"→Str8
End
If Str8="I"
Then
"V"→Str8
End
If Str8="J"
Then
"W"→Str8
End
If Str8="K"
Then
"X"→Str8
End
If Str8="L"
Then
"Y"→Str8
End
If Str8="M"
Then
"Z"→Str8
End
If Str8="N"
Then
"A"→Str8
End
If Str8="O"
Then
"B"→Str8
End
If Str8="P"
Then
"C"→Str8
End
If Str8="Q"
Then
"D"→Str8
End
If Str8="R"
Then
"E"→Str8
End
If Str8="S"
Then
"F"→Str8
End
If Str8="T"
Then
"G"→Str8
End
If Str8="U"
Then
"H"→Str8
End
If Str8="V"
Then
"I"→Str8
End
If Str8="W"
Then
"J"→Str8
End
If Str8="X"
Then
"K"→Str8
End
If Str8="Y"
Then
"L"→Str8
End
If Str8="Z"
Then
"M"→Str8
End


If Str8≠"θ"
Then
(Str8+Str7+Str6+Str5+Str4+Str3+Str2+Str1)→Str9
Disp Str9
End

If Str8="θ" and Str7≠"θ"
Then
(Str7+Str6+Str5+Str4+Str3+Str2+Str1)→Str9
Disp Str9
End

If Str8="θ" and Str7="θ" and Str6≠"θ"
Then
(Str6+Str5+Str4+Str3+Str2+Str1)→Str9
Disp Str9
End

If Str8="θ" and Str7="θ" and Str6="θ" and Str5≠"θ"
Then
(Str5+Str4+Str3+Str2+Str1)→Str9
Disp Str9
End

If Str8="θ" and Str7="θ" and Str6="θ" and Str5="θ" and Str4≠"θ"
Then
(Str4+Str3+Str2+Str1)→Str9
Disp Str9
End

If Str8="θ" and Str7="θ" and Str6="θ" and Str5="θ" and Str4="θ" and Str3≠"θ"
Then
(Str3+Str2+Str1)→Str9
Disp Str9
End

If Str8="θ" and Str7="θ" and Str6="θ" and Str5="θ" and Str4="θ" and Str3="θ" and Str2≠"θ"
Then
(Str2+Str1)→Str9
Disp Str9
End

If Str8="θ" and Str7="θ" and Str6="θ" and Str5="θ" and Str4="θ" and Str3="θ" and Str2="θ"
Then
Str1→Str9
Disp Str9
End
Use the [code] tags! Maybe a missing Else?
The problem is that you overwrite a string with its coded value which may then match a later if. Here's a more reasonable implementation of this program:
Code:
Input Str1
"ABCDEFGHIJKLMNOPQRSTUVWXYZ
For(A,1,length(Str1
Ans+sub(Ans,remainder(inString(Ans,sub(Str1,A,1))+12,26)+1,1
End
sub(Ans,27,length(Str1
jacobly wrote:
The problem is that you overwrite a string with its coded value which may then match a later if. Here's a more reasonable implementation of this program:
Code:
Input Str1
"ABCDEFGHIJKLMNOPQRSTUVWXYZ
For(A,1,length(Str1
Ans+sub(Ans,remainder(inString(Ans,sub(Str1,A,1))+12,26)+1,1
End
sub(Ans,27,length(Str1


Not that it matters much, but couldn't you modify line 4 to

Code:
Ans+sub(Ans,remainder(inString(Ans,sub(Str1,A,1))+13,26),1

just to save on a little space, since just adding 13 instead of 12 to the instring position already adds 1 to the remainder? It's a cool little For loop though, I like it a lot
readroof2 wrote:
Not that it matters much, but couldn't you modify line 4 to

Code:
Ans+sub(Ans,remainder(inString(Ans,sub(Str1,A,1))+13,26),1

just to save on a little space, since just adding 13 instead of 12 to the instring position already adds 1 to the remainder? It's a cool little For loop though, I like it a lot


Unfortunately, you cannot because remainder(X,26) returns a number from 0 and 25 which will not work with the sub( which expects a number from 1 to 26.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement