Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.65 KB | None | 0 0
  1. New Skills Practiced (Learning Goals)
  2.  
  3. Problem solving and debugging.
  4. Use of selection structures (making decisions).
  5. Use of repetition structures (looping).
  6. Formatting output to meet specifications.
  7.  
  8. The data files for this assignment will contain several data sets. Each data set will consist of several positive and/or negative integers terminated by the sentinel value, 0. Each value in the file will be separated by whitespace. Here is a sample data file with 2 data sets:
  9. 4 12 -32 0
  10. 715 45
  11. 47 -3 21
  12. 19 0
  13.  
  14. Design and implement a C++ program that will do the following.
  15.  
  16. Display your name, lecture section #, and assignment #.
  17. Read the data from a file (as described above) using Linux redirection and
  18. generate a table that displays
  19. a data set #, the number of values in the data set, the sum of the values in the data set, the average of the values in the data set, the largest value in the data set and (if the largest value is greater than 0) the number of factors it has
  20. When all data has been read and the table is complete, display the total number of non-zero values read, their sum, and average with appropriate labels.
  21.  
  22. NOTES:
  23.  
  24. Assumptions about input: (you do not have to test for these conditions)
  25. the data file will exist, will not be empty, and all input values will be integers
  26. each data set will be terminated by a 0
  27. a data set can be empty (no values preceding the 0)
  28. each input value will be separated by whitespace (blanks and/or linefeeds)
  29. the last line in the data file will be terminated with a linefeed ('\n')
  30. Program must be designed to run in batch mode (no prompts) via Linux redirection.
  31. Display averages as floating point numbers with 3 digits to the right of the decimal.
  32. If there are no values in a data set, leave the average column blank.
  33. Display data set #, counts, and sums as integers.
  34. Right justify all numbers displayed in table. The maximum number of columns needed to display a number (including negative sign and decimal) is 11. Make sure numbers do not run together in the table.
  35. Display final count and sum as integers with labels.
  36. Display final average with 3 digits to the right of the decimal and a label.
  37.  
  38. Documentation (12 pts)
  39. When the program compiles and runs correctly, add the following documentation (comments) to your source file (.cpp file).
  40.  
  41. Place a comment with your name, lecture section#, and assignment # at the beginning of the file.
  42. List the expected input to the program. If the input will be read from a file, list (describe) the file's content.
  43. List the expected output of the program. (If the input values are supposed to be displayed, include them in the output list.)
  44. Provide a meaningful description of what each constant and major variable represents in the program. Place these comments with the constant/variable declarations.
  45.  
  46. Programming Style (8 pts)
  47.  
  48. Make sure that your program is formatted to promote readability. (indent, 1 statement per line, blank lines, etc)
  49. Make sure all constants and variables have meaningful names.
  50. Try to use a naming convention that makes it easy to distinguish between constants and variables.
  51. Make sure all constants are declared before the start of the main function and that all variables are declared at the beginning of the main function.
  52.  
  53. Sample terminal session:
  54. [lee@bobby keys]$ more data4three
  55. 4 12 -32 0
  56. 715 45
  57. 47 -3 21
  58. 19 0
  59. 0
  60. 5 33 172 222 14
  61. -15 123 0
  62. [lee@bobby keys]$ g++ assign03.cpp
  63. [lee@bobby keys]$ ./a.out < data4three
  64. Lee Misch LecSec#10__ Assignment #3
  65.  
  66. Data Largest #
  67. Set# Count Sum Average Largest # Factors
  68. ================================================================
  69. 1 3 -16 -5.333 12 6
  70. 2 6 844 140.667 715 8
  71. 3 0 0 0
  72. 4 7 554 79.143 222 8
  73. ================================================================
  74. Count of all non-zero #s: 16
  75. Sum of all non-zero #s: 1382
  76. Average of all non-zero #s: 86.375
  77.  
  78. Submitting your program
  79.  
  80. Test your program with enough data to verify that it works properly. The sample data file shown above does not test all requirements.
  81. Make sure you have included the required documentation.
  82. Make sure it compiles and runs on bobby.cs.unlv.edu AFTER adding the documentation.
  83. Follow the steps described in the submit handout.
  84.  
  85. Return to assignments list
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement