*
Computer Programming II
Programming Assignment 4 - ADT Sorted List (KSQP) *

Problem

Write a program to process an amateur radio log file. Your program should extract locations from the log file and enter them into a sorted list. Since our implementation of Sorted List doesn't allow duplicate entries, the list will contain only unique locations (called multipliers). After the list is created, print out the list to a text file and and use the number of multipliers to calculate the total score.

Specification

The log is a text file with each line a separate contact in the following format:

0         1         2         3         4         5         6         7         8
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234
                                                                                 LOC
QSO:  7048 CW 2009-08-29 1401 W0BH/M       599      REN    KC7ZYS       599      WA  

Lines containing contacts always start with QSO. Locations are 2 or 3 characters in length and always alphabetic.

Locations may be duplicated in the log file but should only appear once in the list .

Use ADT Sorted List as developed in class to create the list of locations. The choice of implementations is yours.

Discussion

Before working on this program, make the necessary changes to your SortedList implementation to allow for duplicate call insert attempts. InsertItem needs to be changed to ignore these inserts since the item is already in the list. You have likely already made these changes as part of another class assignment.

Test your changes to InsertItem to confirm that it handles duplicate entries correctly.

Create a project named KSQP in your CP2 folder containing the Logs program developed in class. Rename this program KSQP.cpp and import it into your KSQP project. Confirm that this program runs correctly on the log file named W0BH.LOG.

Copy your ADT SortedList header and implementation files to the KSQP folder. You will need both SortedList and Itemtype classes.

Create a short log file (5-10 calls) named TEST.LOG to use during program development and testing.

Change the Itemtype class to reflect the data type you will now be storing.

Your program should be called ksqp.cpp and it should process calls as follows:

	prompt the user for a log file name
        open the file and confirm success

	while not end-of-file
            read a line from the log
            increment line count
            if the line starts with QSO
		extract the location
                if TRACE print location to screen
                if location is 3 characters in length, location = "KS"
            	insert the location into the sorted list
                increment QSO count
	    end if
	end while

	print line count
	print QSO count

	print multiplier count (ie length of list).

        print multiplier list to out.txt

The logfile program should give you a clue as to how to extract the calls.

Once you get the program working correctly, add code to calculate the final score as follows:

        1. Each CW contact is worth 3 points
        2. Each PH contact is worth 2 points
        3. Score = ( CW points + PH points ) * multiplier count

On the screen and at the bottom of out.txt, print the number of CW contacts, the number of PH contacts, and the final score.

Comment your program for readability and ease of maintenance.


Submission

Complete project KSQP in your H:\CP2 folder by the due date. Print out each of your files to hand in.

*

This page maintained by bobh@hesston.edu