Answered step by step
Verified Expert Solution
Question
1 Approved Answer
i need help with this c++ program This lab addresses the following major topics: - 2d arrays - Vectors, array of vectors - Input/output files
i need help with this c++ program
This lab addresses the following major topics: - 2d arrays - Vectors, array of vectors - Input/output files - Introduction of Structures You will find the instruction file along with any additional files on blackboard. In this category of lab activity students are expected to write a complete program during the lab and submit the compiling program on blackboard before the end of the lab session. The instructor will give a brief description of the assignment and provides limited help throughout the lab. Students can use the textbook, class notes or sample programs to complete the assignment, but are PROHIBITED from collaborating with one another. Requirements for the program: This lab assignment has 4 parts, for grading purposes, separate each part in your program using a comment line such as: Part I: In an input file called inData, txt, we have 6 lines of data in the following pattern per line: One-word name of a student followed by 5 assignment scores (all integers). An example of this file is as follows: KimSam60758280909280787568 You are asked to write a program that reads the name of the students in a Id array of string called names and read the scores of these students in a 2d array called scores in which every row will store the scores for a given student. This makes for a 6 by 52d array of integers. In this 2d array the first column has scores for assignment #1, the second column has scores for assignment #2, etc. Here is what your program should do: - You should output the name of every student and their average score (as an integer) both on the sereen as well as write it to an output file called outData, txt. - For every assignment output the highest score as well the name of the student who made the highest score for that assignment on the screen. You MUST use the following functions in order to accomplish the above tasks: void averageperstudent ( string [ 1 , int [ ] [numGrades], int); vold maxGradeperassign ( string [ ], int [ l (numGrades], int); function access to the output file, you must declare the output stream object globally, and use it to connect to our output file outData, txt in main function. This way averagePerstudent function will have access to an of st ream object who is already connected to a file. So a sample output for part l of this assignment would be: Kim77 Sam78 For assignment 11 Joe has made the highest score of 99. Part II: For part II of this assignment, you will be reading data from the file you created in part I. Here are the requirements for this part: You are going to apply the rule that considers any grade less than a grade of B as a failing grade. The range for grades of A and B are the regular standard of 90 and higher for A, and 80 through 89 for B, any score less than 80 will be an F. In order to keep track of students who made a grade of A, B and F, you are asked to use three vectors of type string called AList, BList, and FList to store the names of students. We use vectors since we do not know how many students made A, or B or F. You read the file and determine the students' grades and then add their name to the proper vector. So the report that you should output for this part is as follows. Obviously you will have a number and/or a list of names for each of the following lines: The number of students who made A : The list of students who made A : Part III: Important Note: The code for this part MUST ONLY rely on the vectors that you created in part II. You cannot use any other segments of code you wrote or even the files in this program here for Part III. We are looking at a scenario in which we can process finding the grade category of a student based on their first name and using ONLY the vectors that we have created. (You don't need to worry about duplicates.) What is the challenge here? Do you agree that three separate vectors do not present a logical framework to run a search like what we have in mind? Specially that the vectors are of type you with a strategy to solve our seareh problem? What do we get out of an array, that we could not get out of 3 independent vectors? Is it anything other than "indexed positioning/configuring of these scattered vectors"? Think of it this way: A vector associated with an index, is a vector with an "identity" that can be efficiently searched for and/or categorized. After you store a vector in an array index, you can access each member of the vector via the array, using double brackets like a 2d array. Remember vectors are Id arrays after all. So this is what you need to do: Only using the three vectors that you created in Part II, allow the user to give you a name in order for you to report back which grade group that person belonged to if you could ever found them. Here is a sample: Please enter the student's name: Kim Kim's grade is: F Part IV: By the time you get to do this lab, we have covered structures in C++. So, here I want you to practice with structures: Define Student to be a structure that contains the name of the student (atring) as well as their letter grade (char). After Part III of your program, you have an array of 3 vectors, and you know each vector falls into what grade category. Dynamically allocate an array of type student, and populate it based on your vector array. Use the following function to display your dynamic array on the screen: void displayArrayoestructs (Student(1, int); Are you surprised by the pattern of your output? Discuss that with your instructor. Here is a sample run of this program for your reference: Kim 78 Part I Sam 79 John 87 Sue 84 Joe 90 Bob 91 For assignment 1 Joe has made the highest grade of 99 For assignnent $2Kim has made the highest grade of 89 For assignnent i3 Sam has made the highest grade of 95 For assignment =4Bob has made the highest grade of 98 For assigntent IS John has made the highest grade of 95 Part II The number of students who made A: 2 The list of students who made A: Joe Bob The number of students who made 8:2 The Uist of students who made B: John Sue The number of students falled: 2 The list of students who failed: Kin San Part III Please enter the student's namet 10 e. KimSam75JohnSueJoeBob6080908099918995817884829078788091958068929089987595929089 This lab addresses the following major topics: - 2d arrays - Vectors, array of vectors - Input/output files - Introduction of Structures You will find the instruction file along with any additional files on blackboard. In this category of lab activity students are expected to write a complete program during the lab and submit the compiling program on blackboard before the end of the lab session. The instructor will give a brief description of the assignment and provides limited help throughout the lab. Students can use the textbook, class notes or sample programs to complete the assignment, but are PROHIBITED from collaborating with one another. Requirements for the program: This lab assignment has 4 parts, for grading purposes, separate each part in your program using a comment line such as: Part I: In an input file called inData, txt, we have 6 lines of data in the following pattern per line: One-word name of a student followed by 5 assignment scores (all integers). An example of this file is as follows: KimSam60758280909280787568 You are asked to write a program that reads the name of the students in a Id array of string called names and read the scores of these students in a 2d array called scores in which every row will store the scores for a given student. This makes for a 6 by 52d array of integers. In this 2d array the first column has scores for assignment #1, the second column has scores for assignment #2, etc. Here is what your program should do: - You should output the name of every student and their average score (as an integer) both on the sereen as well as write it to an output file called outData, txt. - For every assignment output the highest score as well the name of the student who made the highest score for that assignment on the screen. You MUST use the following functions in order to accomplish the above tasks: void averageperstudent ( string [ 1 , int [ ] [numGrades], int); vold maxGradeperassign ( string [ ], int [ l (numGrades], int); function access to the output file, you must declare the output stream object globally, and use it to connect to our output file outData, txt in main function. This way averagePerstudent function will have access to an of st ream object who is already connected to a file. So a sample output for part l of this assignment would be: Kim77 Sam78 For assignment 11 Joe has made the highest score of 99. Part II: For part II of this assignment, you will be reading data from the file you created in part I. Here are the requirements for this part: You are going to apply the rule that considers any grade less than a grade of B as a failing grade. The range for grades of A and B are the regular standard of 90 and higher for A, and 80 through 89 for B, any score less than 80 will be an F. In order to keep track of students who made a grade of A, B and F, you are asked to use three vectors of type string called AList, BList, and FList to store the names of students. We use vectors since we do not know how many students made A, or B or F. You read the file and determine the students' grades and then add their name to the proper vector. So the report that you should output for this part is as follows. Obviously you will have a number and/or a list of names for each of the following lines: The number of students who made A : The list of students who made A : Part III: Important Note: The code for this part MUST ONLY rely on the vectors that you created in part II. You cannot use any other segments of code you wrote or even the files in this program here for Part III. We are looking at a scenario in which we can process finding the grade category of a student based on their first name and using ONLY the vectors that we have created. (You don't need to worry about duplicates.) What is the challenge here? Do you agree that three separate vectors do not present a logical framework to run a search like what we have in mind? Specially that the vectors are of type you with a strategy to solve our seareh problem? What do we get out of an array, that we could not get out of 3 independent vectors? Is it anything other than "indexed positioning/configuring of these scattered vectors"? Think of it this way: A vector associated with an index, is a vector with an "identity" that can be efficiently searched for and/or categorized. After you store a vector in an array index, you can access each member of the vector via the array, using double brackets like a 2d array. Remember vectors are Id arrays after all. So this is what you need to do: Only using the three vectors that you created in Part II, allow the user to give you a name in order for you to report back which grade group that person belonged to if you could ever found them. Here is a sample: Please enter the student's name: Kim Kim's grade is: F Part IV: By the time you get to do this lab, we have covered structures in C++. So, here I want you to practice with structures: Define Student to be a structure that contains the name of the student (atring) as well as their letter grade (char). After Part III of your program, you have an array of 3 vectors, and you know each vector falls into what grade category. Dynamically allocate an array of type student, and populate it based on your vector array. Use the following function to display your dynamic array on the screen: void displayArrayoestructs (Student(1, int); Are you surprised by the pattern of your output? Discuss that with your instructor. Here is a sample run of this program for your reference: Kim 78 Part I Sam 79 John 87 Sue 84 Joe 90 Bob 91 For assignment 1 Joe has made the highest grade of 99 For assignnent $2Kim has made the highest grade of 89 For assignnent i3 Sam has made the highest grade of 95 For assignment =4Bob has made the highest grade of 98 For assigntent IS John has made the highest grade of 95 Part II The number of students who made A: 2 The list of students who made A: Joe Bob The number of students who made 8:2 The Uist of students who made B: John Sue The number of students falled: 2 The list of students who failed: Kin San Part III Please enter the student's namet 10 e. KimSam75JohnSueJoeBob6080908099918995817884829078788091958068929089987595929089 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