CS 107 – Introduction to Computing and Programming – Spring 2013 Homework Assignment 7 ( Draft 3.0 - Hopefully Final ) Fun with Linked Lists Due: Monday 29 April at 8:00 A.M. Optional hard copy may be turned in to TA during lab. Overall Assignment For this assignment, you are to write a program that reads in sentences character-by-character, creates a linked list out of the character stream, and then performs various operations on the resulting list(s). Node Structure The linked list node that you create for this assignment shall be named “node”, and shall have at a minimum the following fields: struct node { char c; int sequence, totalSequence; struct node * next; }; where: The char c is a character read in from the keyboard. sequence is the original position of this character within the sentence, starting from 1. I.e. the first character in the sentence will have sequence 1, the second 2, etc. totalSequence is the same idea as sequence, but the numbers are since the program started. So for example, if the first sentence read contains 20 characters, ( not counting the newline character ), then the first character of the second sentence would have a sequence number of 1, but a totalSequence number of 21. Program Operation After reporting your name and explaining to the user what the program does, your program should do the following: 1. Ask the user to enter a sentence. 2. Read the characters one-by-one, until the newline character ( ‘\n’ ) is read in. For each character read in: A. Create a new node, using dynamic allocation ( malloc ), and fill in the node fields. B. Add the node to the beginning of a linked list for this sentence. 3. Once the sentence is stored in a linked list, give the user a list of operations supported, ( see below ) and allow them to choose which one(s) to perform. Based upon their choice, use a switch to perform the operation requested and print out the results. 4. Two choices on the list must be to quit the program and to read in the next sentence. In the latter case the current sentence must be either deleted or added to a linked list of past sentences. 5. Repeat from step 1 until the user enters "done". Note that this test should be case-insensitive. 6. Print overall summary statistics, such as number of characters and sentences processed. Required Functions void print( struct node *head ); o This function prints out the characters of the linked list, in the order of the list. o Note: Printing the sentence as the linked list is originally created will print backwards from what the user entered, because of the way that the linked list is created. o Alternate: For all functions, if you use typedef to create a type “node”, then you can use that defined type instead of “struct node”. o Skills: Traversing a linked list. Also, printing is always needed. void printReversed( struct node *head ); o This function prints.