CS 210 - Fundamentals of Programming I

Spring 2006 - Programming Assignment 5

20 points

Out: March 21, 2006
Due: March 28, 2006


(6 points) Consider the following problem statement.

Write a program that reads a sequence of real numbers from a file whose name is given by the user. The numbers should be read into an array. You may assume that the maximum number of reals in the file is 100. The program should then determine the largest value, the smallest value, and the average of the values contained in the array using a separate function to compute and return each value, then display these values formatted to always show two digits after the decimal point.
For example, the program output might look like:
   Enter the name of the file: arraytest.dat

   The largest value is: 123.40
   The smallest value is: -34.60
   The average of the values is: 52.03
Where arraytest.dat is a file containing the values: 123.4 -34.6 67.3


Write an analysis and design for this program. (Note that it does not loop.) You should assume that you have the functions InteractiveOpen and ReadArray introduced in the lecture and in-class exercise on 3/21/06. You should use these functions in your design, but do not provide an analysis and design for them (since they were already done in lecture). The remainder of the program must be designed to use the three functions specified above. Write this portion of the assignment in as a comment block before the main program in your implementation file.


(14 points) Implement the program described above in C++. Note: you should copy the implementations of the InteractiveOpen and ReadArray functions from the in-class exercise of 3/21/06 to your new program. Name your source file array.cpp.


Follow the guidelines in the A C++ Programming Style Guideline handout. As stated in the syllabus, part of the grade on a programming assignment depends on how well you adhere to the guidelines. The grader will look at your code listing and grade it according to the guidelines.


Turn in a hardcopy printout of your program (that includes the analysis and design) to the instructor, and submit your source file (array.cpp) by emailing it as an attachment to cs210@csserver.evansville.edu by 5pm on the due date. (Make sure you send it to csserver. If you send to just evansville.edu, it will not be delivered.)


Note 1: An input file may be created by using Visual Studio by choosing File, then New, then File. For Categories, choose General, then in Templates, choose Text File. Click on Open. This will give you a text file window. Type in the data, then use File, then Save As, and save the file in the project folder with whatever name you wish.


Note 2: In KC-267, when a program is run using Start Without Debugging, the default folder is set to C:\WINDOWS (because the .NET system doesn't trust a program coming from a network drive that it's not debugging), so all input (and output) files must be in this folder. On the other hand when a program is run using Start Debugging, the input (and output) files are expected to be in the project folder. If you develop this program on your own machine with the project folder on the local drive, then the input (and output) files will be expected to be in the project folder in both cases.



Converted using latex2html on Tue Mar 21 00:16:28 CST 2006