File I/O Exercise

From WLCS

Objective:

  • You will be creating a program that prompts the user to enter a bunch of names, which will be written to a file.
  • You will also create another program that reads the contents of a particular file, and allows the user to search for a particular name.

Resources:

File Output Program:

  1. Using a loop, you will continuously prompt the user to enter a name
    1. After the user inputs the name, you will append it to a list of names
    2. If the user ever inputs nothing, then you will break out of the loop or end the loop
  2. You should prompt the user to enter a filename to be used
  3. Create a new file to write out to, using the filename provided by the user
  4. Your program should traverse the list of names and write out to file, every name in the file
  5. Close your file

File Input Program:

  1. Prompt the user to enter a filename
  2. Open the file for reading
  3. Read all of the contents of the file into a list
  4. Prompt the user to enter a name that they wish to search for
  5. Use a loop to traverse the list of names, and check if the name is found in the list
  6. You should output to the user whether or not the name is found in the list