I've pasted my project description, but the only issue i've run into thus far is trying to take my sorted array of integers and placing them into two separate arrays (one array containing the separate ints, the the other containing the amount of times that particular int occurs). I'm not sure why, but my two arrays are not setting correctly. I'm not really new to programming, only the syntax of C++. My code is here http://pastie.org/2576163
. I considered originally using a 2D array, but that was also giving me issues
• To learn unit testing
• To develop test drivers
• To use arrays and file I/O to write a C/C++ program.
Write and test a program that reads a list of integers from a file and stores integers in an
array of type int. Your program determines how many entries are used. The output is a
file containing a two-column list. The first column is a list of the distinct array elements;
the second column is the count of the number of occurrences of each element. The list
should be sorted on entries in the first column, largest to smallest.
For example, if the input file contains the following list of integers:
12 3 -12 4 1 1 -12 1 -1 1 2 3 4 2 3 -12
then, the output file should be
Your program also must respond to the following queries. Note: each query should be
respond by one function in your program.
• How many different integers occur in the list?
• What is the average frequency of occurrence for each integer?
• Which integer is the largest?
• Which integer is the smallest?
• Which integer appears the most often? How many times?
• Which integer appears the least often? How many times?
You must provide the following user interface. The user input is depicted as Bold, but
you do not need to display user input in bold. Please replace “Xiao Qin” with your name.
Your program must follow the style of the above user interface.
A unit test verifies that a function or set of functions under test meet the requirements.
You need to isolate a single function and test only that function.
Since you have to treat each function as a separate unit, you transform one big task into
a series of smaller, more manageable tasks. You must test functions outside the
program (i.e., your first program). Therefore, you need to write a separate (i.e., a
second one) program called driver program to test all the functions implemented in first
program. The second program contains test drivers for your first program.
A sample driver program is illustrated in the next section.
A Sample Driver Program:
The following code shows you how to write a program to test the function unitPrice().
Programs like this one are called driver programs. These driver programs are temporary
tools and can be quite minimal. They need not have fancy input routines. They need not
perform all the calculations the final program will perform. All they need do is obtain
reasonable values for the function arguments in as simple a way as possible—typically
from the user—then execute the function and show the result.
*** Welcome to Xiao Qin’s word count program ***
Enter the first input file name: input.txt
The list of integers in file input.txt is:
12 3 -12 4 1 1 -12 1 -1 1 2 3 4 2 3 -12 -12
The following list will be sorted in a file:
How many different integers occur in the list? 17
What is the average frequency of occurrence for each integer? 2.83
Which integer is the largest? 4
Which integer is the smallest? -12
Which integer appears the most often? How many times? -12 5
Which integer appears the least often? How many times? -1 1
*** Goodbye. ***
Write a short program in C++. Compile and run it using the g++ compiler on a Linux box
(either in Shop 3, computer labs in Shelby, your home Linux machine, a Linux box on a
virtual machine, or using an emulator like Cygwin). If your program is not compiled by
g++ in Linux, you will receive no point.
Note: If your program contains compilation errors, you will lose all 20 points
because the TA will not grade your homework assignment.
1. (1 point) Use comments to provide a heading at the top of your code containing
your name, Auburn Userid, filename, and how to compile your code. Also
describe any help or sources that you used (as per the syllabus).
2. (1 point) Your source code file should be named as “<username>_hw6.cpp” and
“<username>_hw6_driver.cpp” (for example, mine would read
“xzq0001_hw6.cpp” and “xzq0001_hw6_driver.cpp”).
3. (1 point) Usability of your program (e.g., user interface)
4. (8 points) Correctness of your first program
5. (8 points) Correctness of your test driver
6. (1 points) Readability of your source code.
You will lose points if you: do not use the specific program file name, or do not have
a comment block on EVERY program you hand in.
• Submit your first program’s source code called “<username>_hw6.cpp” through
the Blackboard system.
• Submit your driver program’s source code file named as
“<username>_hw6_driver.cpp” through the Blackboard system.
You will be given a period of 72 hours to read and respond to the comments and
grades of your homework assignment. The TA may use this opportunity to
address any concern and question you have. The TA also may ask for additional
information from you regarding your homework. After the rebuttal period, your
grad Rebuttals may be at most 2500 words long, but effective rebuttals are likely
to be brief, of course.