Public paste
assignment7
By: polexican | Date: Dec 6 2006 18:05 | Format: None | Expires: never | Size: 2.32 KB | Hits: 1355

  1. Assignment #7 – Arrays and functions                            Due Date: 11/30/06
  2.  
  3. Problem: (100 points) Develop an algorithm for solving the problem described below and then write its program.
  4. This program must read the test grades for a group of students from an input file called indata7.txt data, curve the grades and send the result (curved grades) to a file called oudata7.txt.   Grades are whole numbers.
  5.  
  6.                                                
  7.  
  8. Assume that there could be at most data for 15 students in the input file.
  9.  
  10. Your main( ) function must open the files, check that there are no problems opening them, and then call three functions:
  11.  
  12. 1) GetData: reads the input data from indata7.txt into an array grades and returns it to the main function together with the quantity of grades read. It receives the input file stream variable as a parameter.
  13.  
  14. 2) CurveData: receives the grades array and the number of grades to process, curves the grades and returns it to main(). It curves the grades by multiplying each grade by the factor 100/MAX_GRADE, where MAX_GRADE is the grade corresponding to the highest test grade.
  15.  
  16. 3) PrintData: prints the output (curved grades) to file outdata7.txt. It receives the output file stream variable as a parameter. It also receives the modified or curved grades array and the quantity of grades to be printed.
  17. For example the output file will contain the following information:
  18.  
  19. Actual Grades           Curved Grades
  20.         88                              97
  21.         76                      84
  22.         69                      77
  23.         58                      64
  24.         75                      83
  25.         86                      96
  26.         74                      82                     
  27.         90                         100
  28.         84                      93
  29.         78                      87
  30.        
  31. Finally, main() must close the files.
  32.  
  33. IMPORTANT: since you can get less than 15 grades from the input file, your program must keep track of how many grades are read in order to work only with them when curving and printing them out.
  34.        
  35. IMPORTANT:
  36. _ do not use global variables to pass information among functions.
  37. _ use reference and value parameters accordingly, to exchange information among the functions.
  38. _ before start working on the program, write on paper the algorithm to solve the problem. Distinguish clearly which are the value parameters and which are the reference parameters by understanding what must be passed from the main function to the functions and what must be passed from the functions to the main function.
  39.  
  40. Write the algorithm in a text file and submit it along the source program (.cpp) through WebCT.
  41.