"C++"编程代写,"C++"程序代写
Student List
A teacher wants to list all her students’ full names, considering only for the two students at the front and the end of the list that must be in alphabetical order. That meant the student at the top and at the end of the list will be set alphabetically according to their full name.
Write a C++ program that can help her with the issue. The list of names could be either read in from an external text file or entered from the keyboard, one full name at a time.
Once all the names have been read in, the program reports which name should be at the top of the list, and which name should be at the end of the list, in alphabetical order of their names. Also, the list of names must be displayed on the screen, together with the original order that their names were entered, for the teacher to check back of her record.
Assume that no two students have the same name. Using an array, (or C++ standard library vector, set, list), is not allowed and will have no credit, absolutely.
Lastly, allow your program to run continuously as often as the user wishes (for another set of names). Before ending the program, your name as the programmer must be displayed.
Input validation: the number of students must be in the range of 5 to 45, inclusively.
Hint: Why is array not allowed? Because there is no need for sorting alphabetically all the names. (considering only for the two students at the front and the end of the list that must be in alphabetical order.) So, use an external file as a temporary place to store all the names entered, and use string comparison with relational operators, (<, >) to check for their alphabetical order.
1)
// File stream object to handle reading/writing from/to external text file
ofstream outFile; // ofstream object for output
ifstream inFile; // ifstream object for input
2)
// To read in a full name entered from keyboard
cout << "\nEnter the full name of student " << ++count << ": "; // int count
getline(cin, current, '\n'); // string current; Remember #include
3) Write out to an external file after reading in a full name. After done with the reading and you already decided the top and end names, the file name will be re-opened and read back all the names, one at a time. That’s the reason we don’t need array or vector. Remember 'set' in library is actually a kind of vector.
4) All external text files must be stored in a specific location so that it will work in Visual Studio 2019. That is the project folder. To read in, the file must be existing or created in advance. To write out to an external file, which will be created as you started to write out, and all data previously stored will be deleted
