Difference between revisions of "E-mail Harvester Assignment"

From WLCS
(New page: '''Objective:''' * Be able to define functions with parameters * Be able to call functions with parameters * Be able to use while loops * Be able to traverse a string * Be able to manipula...)
 
Line 7: Line 7:
  
 
'''Directions:'''
 
'''Directions:'''
# Write a function named findAtSymbol(strng) that takes a single parameter, strng, which is a string. The function should traverse the string and find the "@" symbol. Your function should then return the index of the "@" symbol
+
# Write a function named '''findAtSymbol(strng)''' that takes a single parameter, strng, which is a string. The function should '''traverse''' the string and find the "@" symbol. Your function should then '''return''' the index of the "@" symbol
# Recreate the find function from Chapter 7. find(strng, ch, index) should return the location of the character ch in string strng, BUT the search should start at index
+
# Recreate the find function from Chapter 7. '''find(strng, ch, index)''' should '''return''' the location of the character ch in string strng, BUT the search should start at index
# Create a find function that does the same thing as the above find function, but instead of searching forwards, make it search backwards. Name the function findBackwards(strng, ch, index).
+
# Create a find function that does the same thing as the above find function, but instead of searching forwards, make it search backwards. Name the function '''findBackwards(strng, ch, index)'''. findBackwards() should also '''return''' an index
 
# Prompt the user for a sentence that contains an e-mail address
 
# Prompt the user for a sentence that contains an e-mail address
# Using the functions that you defined, isolate the e-mail address by finding the space before the @ symbol and the space after the @ symbol.  You should print out the slice of the string that contains the e-mail address.
+
# Using the functions that you defined, isolate the e-mail address by finding the space before the @ symbol and the space after the @ symbol.  You should print out the '''slice''' of the string that contains the e-mail address.

Revision as of 14:18, 16 December 2008

Objective:

  • Be able to define functions with parameters
  • Be able to call functions with parameters
  • Be able to use while loops
  • Be able to traverse a string
  • Be able to manipulate strings

Directions:

  1. Write a function named findAtSymbol(strng) that takes a single parameter, strng, which is a string. The function should traverse the string and find the "@" symbol. Your function should then return the index of the "@" symbol
  2. Recreate the find function from Chapter 7. find(strng, ch, index) should return the location of the character ch in string strng, BUT the search should start at index
  3. Create a find function that does the same thing as the above find function, but instead of searching forwards, make it search backwards. Name the function findBackwards(strng, ch, index). findBackwards() should also return an index
  4. Prompt the user for a sentence that contains an e-mail address
  5. Using the functions that you defined, isolate the e-mail address by finding the space before the @ symbol and the space after the @ symbol. You should print out the slice of the string that contains the e-mail address.