C++ please. Can someone help please with the full project. I get bit and pieces, but may someone answer this fully. stud
Posted: Sat Nov 27, 2021 2:20 pm
C++ please.
Can someone help please with the full project. I get bit and
pieces, but may someone answer this fully.
student.dat and getNumber.cpp have been provided at the end.
Please help and thank you!
Due: 11:59 PM on Sunday, November 21, 2021 PROGRAM DESCRIPTION In this project, you have to write a C++ program to keep track of grades of students using structures and files. You are provided a data file named student.dat. Open the file to view it. Keep a backup of this file all the time since you will be editing this file in the program and may lose the content. The file has multiple rows-each row represents a student. The data items are in order: last name, first name including any middle names, student ID (8 digits long), number of tests the student took, and the scores in those tests. Note that each item is separated by commas (), even the last score has a comma after it. Do not change this format. The teacher has given 5 tests to each student, but not all students took all 5 tests. The minimum test score is dropped. You are also provided a .cpp file: getNumber.cpp. It has a single function getNumber which gets the number of student records in the data file. You will need to call this function to create your dynamic arrays. Do not edit this file. PROGRAM REQUIREMENTS 1. As with all projects in this course, your program's output will display your name, your EUID, your e-mail address, the department name, and course number. This means that your program will print this information to the terminal (see the sample output). O 2. Declare and initialize the following global parameters. A global integer constant of type integer to store the number of tests given by the teacher and initialize it to 5. An enumeration constant with values Add, Remove, Display, Search, Results, and Quit, and assign integer values 1,2,3,4,5, and 6 to the data items, respectively. They represent menu choice presented to the user. A structure named Student with the following members. o Name of the student (DO NOT USE SEPARATE VARIABLES FOR FIRST NAME AND LAST NAME) o Student ID of the student o Number of tests taken by the student o An integer pointer for a dynamic array to store the test scores for the student o Average of the test scores 3. In your main function: Display a menu for the user (SEE SAMPLE OUTPUT) that provides the user the following choices. o Add a new student record o Remove an existing student record o Display all records Search for a particular student record using student ID .
. o Export the results to a disk file o Quit the program Using a suitable message, ask the user to make the menu choice using an integer variable. Based on the value entered by the user for menu choice, design a switch-case block to implement the following requirements. o You must use the enumeration constants to set up your cases. o You must use a variable of your enumeration constant type for switching control. o If the user chooses to add a student record ► Call the function add_Student o If the user chooses to remove student record ► Using a suitable message, ask the user the student ID of the student to remove. ► Call the function remove_Student and pass the student ID entered by the user. o If the user chooses to display records Call the function display o If the user chooses to search for a student Using a suitable message, ask the user the student ID of the student to search for. ► Call the function search and pass the student ID entered by the user. o If the user chooses to export results to a disk file. > Call the function exportResults. o If the user choose to quit the program. > Exit the program with a suitable message. o If the user chooses anything else, execute the default case to notify the user of an incorrect choice. > Using a suitable loop, ask the user for the choice again. ► Your program must keep on looping until the user enters the correct choice . 4. Write a function named add_Student. Inside the function: Using a suitable message, prompt the user for the first name, the last name, the student ID, the number of tests taken and the test scores of a student. HINT: The test scores is in a dynamic array and the size of the array is the number of tests. Allocate memory accordingly. Open the data file student.dat and write the data of the student to the file maintaining the given format. You must use the structure members to write the data to the file. This function will be called by the main function. . 5. Write a function named remove_Student. It has a parameter for the student ID of the student to be removed. Inside this function, call function getNumber to get the current number of students in the data file. Create a dynamic array of the structure type Student. Use the number of students in the data file for size of this dynamic array. Open student.dat file for reading.
In a loop, read one line of the file at a time and store appropriate data in the dynamic array. o While reading check if the student ID being read from the file matches the student ID of the student to be removed. o If you find match, use a Boolean flag to store that you have found a match. o Copy the entire file to your dynamic array whether or not you find a match. Close the file. If you have found a match while reading: o Open student.dat file for writing. o Write the contents of the dynamic array into the file, only if the student ID does not match the student ID to be removed. If you have not found a match while reading: o Notify the user with a suitable message to indicate the student does not exist. Close the file. This function will be called by the main function. . 6. Write a function named display. Inside the function, Open the data file for reading. Using the getNumber function and a pointer of type Student, create a dynamic array to read the contents of the file into the dynamic array using a suitable loop. Using a second loop, display the contents of the array in the following format: o Allocate 30 spaces for the entire name o Allocate 15 spaces for the student ID o Allocate 5 spaces each for the test score o You don't need to display the number of tests Close the file This function will be called by the main function. . 7. Write a function named search. This function accepts the student ID of the student to search. Inside the function: Open the data file for reading. Declare a pointer of type Student. You DO NOT need an array here. Using a suitable loop, read each line of the file and store the appropriate data into the appropriate members of the structure pointer. Check if the student ID being read from the file matches the student ID to search. If there is a match: o Set a Boolean flag to true to indicate match has been found. o Display the data corresponding data of the matched student using the following format: > Allocate 30 spaces for the entire name ► Allocate 15 spaces for the student ID ► Allocate 5 spaces each for the test score ► You don't need to display the number of tests If the Boolean is false i.e. no match is found, display an appropriate message for the user, This function will be called by the main function. . .
. . 8. Write a function named exportResults. Inside the function: Open a data file named averages.dat for writing. This file will contain the averages of the test scores for each student along with the student ID. Open student.dat for reading. Create a dynamic array of type Students using a suitable pointer and calling the function getNumber to store the contents of the data file student.dat. In a loop, read the contents of the file and store it in the dynamic array. In a second loop, process each student at a time to compute the average as follows: o Compute the sum of the test scores. o Note that the minimum score is dropped. Call the function named find Minimum (see Step 9) to find the minimum score and subtract it from the total score. o Divide the sum by an appropriate integer to compute the average. o Write the student ID and the average to the averages.dat file. The average column should have one digit after the decimal point. Close both files. This function will be called by the main function. . 9. Write a function named find Minimum that accepts an array of integers and the size of the array as parameters. This function computes the minimum out of the test scores and returns the score. If a student has taken less then 5 tests, the minimum score is O. If a student has taken all 5 tests, the minimum score is the minimum of the 5 scores in the array. This function will be called by the exportResults function. . . 10. Now that you've written and tested your program, make the following changes. Create a file named euidProject2_main.cpp and copy the main function to this file. Create a file named euidProject2_func.cpp and copy all the functions (other than the main function) to this file. Create a file named euidProject2_header.cpp and copy all the global parameters, include fields and function headers to the header file. Make sure you include the header file in the .cpp files. You need to submit these three files to Canvas, where euid should be replaced by your EUID. Compile the files together (including getNumber.cpp) and make sure it works correctly. . . 11. You must follow all the good programming practices of file 1/0 as well as dynamic memory programming throughout your code. 12. Your program must have exactly these listed functions. If you miss a function, you won't get points for that. If write an extra function, you won't get points for that either. The functions are: getNumber find Minimum add_Student remove_Student display search exportResults main . . .
I Smith, John Stevens, 12456214,5, 99, 98, 96, 92, 91, Johnson, Chris, 11058975, 4, 84, 83, 78, 91, abcd, abcd, 11114444, 4, 100, 100, 100, 98, I
#include "euid_header.h" int getNumber(). { ifstream fin; fin.open("student.dat"); if (fin.fail()) { cout<<"File error."<<endl; exit(1); } int count=0; string line; while('fin.eof()) { getline(fin, line); ++count; } fin.close(); return(count); }
Can someone help please with the full project. I get bit and
pieces, but may someone answer this fully.
student.dat and getNumber.cpp have been provided at the end.
Please help and thank you!
Due: 11:59 PM on Sunday, November 21, 2021 PROGRAM DESCRIPTION In this project, you have to write a C++ program to keep track of grades of students using structures and files. You are provided a data file named student.dat. Open the file to view it. Keep a backup of this file all the time since you will be editing this file in the program and may lose the content. The file has multiple rows-each row represents a student. The data items are in order: last name, first name including any middle names, student ID (8 digits long), number of tests the student took, and the scores in those tests. Note that each item is separated by commas (), even the last score has a comma after it. Do not change this format. The teacher has given 5 tests to each student, but not all students took all 5 tests. The minimum test score is dropped. You are also provided a .cpp file: getNumber.cpp. It has a single function getNumber which gets the number of student records in the data file. You will need to call this function to create your dynamic arrays. Do not edit this file. PROGRAM REQUIREMENTS 1. As with all projects in this course, your program's output will display your name, your EUID, your e-mail address, the department name, and course number. This means that your program will print this information to the terminal (see the sample output). O 2. Declare and initialize the following global parameters. A global integer constant of type integer to store the number of tests given by the teacher and initialize it to 5. An enumeration constant with values Add, Remove, Display, Search, Results, and Quit, and assign integer values 1,2,3,4,5, and 6 to the data items, respectively. They represent menu choice presented to the user. A structure named Student with the following members. o Name of the student (DO NOT USE SEPARATE VARIABLES FOR FIRST NAME AND LAST NAME) o Student ID of the student o Number of tests taken by the student o An integer pointer for a dynamic array to store the test scores for the student o Average of the test scores 3. In your main function: Display a menu for the user (SEE SAMPLE OUTPUT) that provides the user the following choices. o Add a new student record o Remove an existing student record o Display all records Search for a particular student record using student ID .
. o Export the results to a disk file o Quit the program Using a suitable message, ask the user to make the menu choice using an integer variable. Based on the value entered by the user for menu choice, design a switch-case block to implement the following requirements. o You must use the enumeration constants to set up your cases. o You must use a variable of your enumeration constant type for switching control. o If the user chooses to add a student record ► Call the function add_Student o If the user chooses to remove student record ► Using a suitable message, ask the user the student ID of the student to remove. ► Call the function remove_Student and pass the student ID entered by the user. o If the user chooses to display records Call the function display o If the user chooses to search for a student Using a suitable message, ask the user the student ID of the student to search for. ► Call the function search and pass the student ID entered by the user. o If the user chooses to export results to a disk file. > Call the function exportResults. o If the user choose to quit the program. > Exit the program with a suitable message. o If the user chooses anything else, execute the default case to notify the user of an incorrect choice. > Using a suitable loop, ask the user for the choice again. ► Your program must keep on looping until the user enters the correct choice . 4. Write a function named add_Student. Inside the function: Using a suitable message, prompt the user for the first name, the last name, the student ID, the number of tests taken and the test scores of a student. HINT: The test scores is in a dynamic array and the size of the array is the number of tests. Allocate memory accordingly. Open the data file student.dat and write the data of the student to the file maintaining the given format. You must use the structure members to write the data to the file. This function will be called by the main function. . 5. Write a function named remove_Student. It has a parameter for the student ID of the student to be removed. Inside this function, call function getNumber to get the current number of students in the data file. Create a dynamic array of the structure type Student. Use the number of students in the data file for size of this dynamic array. Open student.dat file for reading.
In a loop, read one line of the file at a time and store appropriate data in the dynamic array. o While reading check if the student ID being read from the file matches the student ID of the student to be removed. o If you find match, use a Boolean flag to store that you have found a match. o Copy the entire file to your dynamic array whether or not you find a match. Close the file. If you have found a match while reading: o Open student.dat file for writing. o Write the contents of the dynamic array into the file, only if the student ID does not match the student ID to be removed. If you have not found a match while reading: o Notify the user with a suitable message to indicate the student does not exist. Close the file. This function will be called by the main function. . 6. Write a function named display. Inside the function, Open the data file for reading. Using the getNumber function and a pointer of type Student, create a dynamic array to read the contents of the file into the dynamic array using a suitable loop. Using a second loop, display the contents of the array in the following format: o Allocate 30 spaces for the entire name o Allocate 15 spaces for the student ID o Allocate 5 spaces each for the test score o You don't need to display the number of tests Close the file This function will be called by the main function. . 7. Write a function named search. This function accepts the student ID of the student to search. Inside the function: Open the data file for reading. Declare a pointer of type Student. You DO NOT need an array here. Using a suitable loop, read each line of the file and store the appropriate data into the appropriate members of the structure pointer. Check if the student ID being read from the file matches the student ID to search. If there is a match: o Set a Boolean flag to true to indicate match has been found. o Display the data corresponding data of the matched student using the following format: > Allocate 30 spaces for the entire name ► Allocate 15 spaces for the student ID ► Allocate 5 spaces each for the test score ► You don't need to display the number of tests If the Boolean is false i.e. no match is found, display an appropriate message for the user, This function will be called by the main function. . .
. . 8. Write a function named exportResults. Inside the function: Open a data file named averages.dat for writing. This file will contain the averages of the test scores for each student along with the student ID. Open student.dat for reading. Create a dynamic array of type Students using a suitable pointer and calling the function getNumber to store the contents of the data file student.dat. In a loop, read the contents of the file and store it in the dynamic array. In a second loop, process each student at a time to compute the average as follows: o Compute the sum of the test scores. o Note that the minimum score is dropped. Call the function named find Minimum (see Step 9) to find the minimum score and subtract it from the total score. o Divide the sum by an appropriate integer to compute the average. o Write the student ID and the average to the averages.dat file. The average column should have one digit after the decimal point. Close both files. This function will be called by the main function. . 9. Write a function named find Minimum that accepts an array of integers and the size of the array as parameters. This function computes the minimum out of the test scores and returns the score. If a student has taken less then 5 tests, the minimum score is O. If a student has taken all 5 tests, the minimum score is the minimum of the 5 scores in the array. This function will be called by the exportResults function. . . 10. Now that you've written and tested your program, make the following changes. Create a file named euidProject2_main.cpp and copy the main function to this file. Create a file named euidProject2_func.cpp and copy all the functions (other than the main function) to this file. Create a file named euidProject2_header.cpp and copy all the global parameters, include fields and function headers to the header file. Make sure you include the header file in the .cpp files. You need to submit these three files to Canvas, where euid should be replaced by your EUID. Compile the files together (including getNumber.cpp) and make sure it works correctly. . . 11. You must follow all the good programming practices of file 1/0 as well as dynamic memory programming throughout your code. 12. Your program must have exactly these listed functions. If you miss a function, you won't get points for that. If write an extra function, you won't get points for that either. The functions are: getNumber find Minimum add_Student remove_Student display search exportResults main . . .
I Smith, John Stevens, 12456214,5, 99, 98, 96, 92, 91, Johnson, Chris, 11058975, 4, 84, 83, 78, 91, abcd, abcd, 11114444, 4, 100, 100, 100, 98, I
#include "euid_header.h" int getNumber(). { ifstream fin; fin.open("student.dat"); if (fin.fail()) { cout<<"File error."<<endl; exit(1); } int count=0; string line; while('fin.eof()) { getline(fin, line); ++count; } fin.close(); return(count); }