Computer Science Canada Replacing a word with an asterix |
Author: | uknowhoiam [ Wed Dec 17, 2008 4:30 pm ] |
Post subject: | Replacing a word with an asterix |
Here's my question that i have to answer .. Write a program that asks the user to input a word and a letter to search for in that word. Search for the letter in the word. If it is found, replace it with an asterix ?*? and print the resulting string. If not found, notify the user. Your output should look like this: Enter a word: Daddy Enter a letter to search for: g Daddy does not have the letter g in it. ~or~ Enter a word: Hello Enter a letter to search for: l He**o I dont know how to replace a word with an asterix.. i've tried ' letter := * ' but i get an error can someone please help |
Author: | Tony [ Wed Dec 17, 2008 4:48 pm ] |
Post subject: | RE:Replacing a word with an asterix |
what is this "letter" variable, and what is the value of * ? Programming via throwing random things at the source is less forgiving than throwing random words at a text document, and hoping than an essay on your English class' book will come out. Without replacing anything, how would you simply isolate a single letter out of a word? |
Author: | uknowhoiam [ Wed Dec 17, 2008 5:06 pm ] | ||||
Post subject: | RE:Replacing a word with an asterix | ||||
letter is entered by the user this is what i have done so far..
i dont know what to put after 'letter :=' and after the incomplete put command please help Mod Edit: Remember to use syntax tags! Thanks ![]()
|
Author: | Tony [ Wed Dec 17, 2008 5:10 pm ] |
Post subject: | RE:Replacing a word with an asterix |
word and letter are two separate variables. If you change anything in letter (letter := ...) it will not have any affect on the word variable. You might find a tutorial on String Manipulation to be useful. |
Author: | uknowhoiam [ Thu Dec 18, 2008 8:22 pm ] |
Post subject: | RE:Replacing a word with an asterix |
i got it to work : ).... thx for your help tony i read the string manipulation, but it didnt really help me but w/e i got it to work ![]() |
Author: | Tony [ Thu Dec 18, 2008 8:26 pm ] |
Post subject: | RE:Replacing a word with an asterix |
How'd you manage to do that? |
Author: | uknowhoiam [ Fri Dec 19, 2008 3:49 pm ] | ||||||
Post subject: | RE:Replacing a word with an asterix | ||||||
this is my code
Mod Edit: Remember to use syntax tags!
|
Author: | dc116 [ Fri Dec 19, 2008 5:25 pm ] |
Post subject: | RE:Replacing a word with an asterix |
Remember that you have to declare all the variables first. |