Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Student scores This assignment will give you practice with dynamic arrays. You will first create a one-dimensional dynamic array of strings and a two-dimensional dynamic
Student scores This assignment will give you practice with dynamic arrays. You will first create a one-dimensional dynamic array of strings and a two-dimensional dynamic array of integers. Then you will access these arrays to print the data they contain. Sample input file Your program should read an input file students.txt that is similar in format to the following sample: number of students number of scores student's scores name of the course student names C++ 3 John Wayne 3 90 85 100 Frank Snooze 0 Mary Poppins 2 100 99 After the first line, the input file contains one line per student. Each student name is a first name and a last name only, and all the scores are integers. You may assume that there are no errors in the file; in particular, the number of students and the numbers of scores are all correct. There is at least one blank between the input elements. Dynamic arrays Create dynamic arrays to store the data from the input files: A one-dimensional dynamic string array to store the student names. A two-dimensional dynamic integer array (a matrix) to store the student scores. One row of the matrix stores the scores for one student, and there should be a row for each student that contains zero or more integer scores. For this assignment, you must use dynamic arrays and not vectors. Use C++ strings for the names. Your arrays should conceptually be something like this: names rows "John Wayne" "Frank Snooze" "Mary Poppins" on 100 99 Remember that an array variable is actually a pointer to the first element of the array, and that a two-dimensional array is a one-dimensional array of pointers to the one- dimensional arrays of values. Therefore, the student scores matrix is dynamic both in the number of rows and in the number of scores per student. The matrix will be "ragged" since the rows will be different sizes. You must delete your dynamic arrays before your program finishes executing. Expected output Here is the expected output format: STUDENT SCORES for C++ John Wayne 90 85 100 Frank Snooze (none) Mary Poppins 100 99 Your program must operate in this order: 1. Read all the input data and create the dynamic arrays. 2. Print the contents of the dynamic arrays. Program structure Your program structure should have good functional decomposition. You should have at least the following two functions: One function to read the input file and build the dynamic arrays. Another function to print the output from the content of the dynamic arrays, which are passed to it as arguments. You may have other helper functions. Declare your functions with documentation before the main and define them after the main with internal documentation. Carefully decide which parameters should be passed by value or by reference, and which should be const. Your program should have no global variables. Global constants are OK
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started