CS320 Assignment #5
Date assigned: 4/11/05
Date due: 4/25/05
Points: 50

This assignment involves writing a program that can aid in identifying students that have cheated on programming assignments by copying someone elses program and making only cosmetic changes to it. In order to perform this task, we need a program that can analyze another program. The analyzed program will be given an identification number to identify the program. This number should be constructed in such a manner that minor cosmetic changes to a program will result in a program that produces a number quite close to the number of the original program. Numbers from programs written by honest students should be quite different. Use the following formula to produce the identification number:

number = 5 * (number of identifiers) + 
         2 * (number of integers) + 
             (number of characters in all string literals) +
         4 * (number of other symbols)

As input to your program, use the file loan.cpp.

For this assignment, you will need to identify the number of identifiers, integers, characters in string literals, and other symbols where:

1) identifier - a letter followed by zero or more letters or digits
2) integer - a digit followed by zero or more digits
3) literal - a character string enclosed in quote (") marks (e.g. "hi there")
4) other - any character other than those mentioned above which are not: (a) part of a comment or (b)whitespace

Note1: Any symbol must begin and end on the same line.

Note2: Do not count the quote marks as characters in the literal string.

Note3: A comment is denoted by //. All comment characters are to be skipped over and not counted in calculating the final number. The // comment is terminated by the end of the line character.

Note4: Assume that the program loan.cpp is error free (i.e. compiles with no errors).

Note5: Do not count whitespace as anything unless it is within quotes.

Note6: Output the number of: identifiers, integers, literals, others, and the identification number (magic number).

Note7: You will want to read the data file a character at a time. After identifying the character, call the appropriate procedure: identifier, integer, literal, comment, or other to find the end of the string of characters you are processing.

Note8: I will run your program on the test data supplied and one more file that I will not hand out.

Note9: The only procedure you may call from the book's link libarary is WriteDec.

Note10: Design a professional looking UI for this assignment.

Note10: Your program should prompt the user for the file to be examined. After processing the file, output the results specified above.

Note11: There is no length limit on the file.

Note12: As always, bring a hard copy of your program to class and turn in a solution in the CS320S05 Drop Box by 11:00am on the day in which the assignment is due. Name the results folder your last name.


© Douglas J. Ryan/ryandj@pacificu.edu