After x=x+encryptor; you can test to see if x>'z' and if it is then subtract 26
JamesCherrill
... trying to help
8,667 posts since Apr 2008
Reputation Points: 2,636
Solved Threads: 1,476
Skill Endorsements: 33
I don't know how to answer that without just giving you the code (which I won't do for homework). Re-read what I wrote then think about it a bit - there's only one right answer.
JamesCherrill
... trying to help
8,667 posts since Apr 2008
Reputation Points: 2,636
Solved Threads: 1,476
Skill Endorsements: 33
OK. There's no need for so many variables. All you need is
if(x > 'z') x = x - 26;
JamesCherrill
... trying to help
8,667 posts since Apr 2008
Reputation Points: 2,636
Solved Threads: 1,476
Skill Endorsements: 33
If you want to use mixed-case letters like that then you need a more complicared if test - first test to see if your letter is upper or lower case. If it's lower case then use the code you just added, if it's upper case then use the same code but with 'Z' instead of 'z'.
YOu can test if a char is upper or lower case by comparing it with 'Z' - all upper case are <='Z', all lower case are >'Z' in ASCII
JamesCherrill
... trying to help
8,667 posts since Apr 2008
Reputation Points: 2,636
Solved Threads: 1,476
Skill Endorsements: 33
Question Answered as of 11 Months Ago by
JamesCherrill