How do I fix my code so that the program displays the student's full name? I have attached a screenshot of the code's current output as well as the list containing student's full names..Below is my code as it is currently written. #include
C++
Here is the original question for what it is worth. Please do not give me an answer you found on Chegg. I have one of those accounts too. Please read carefully, I have submitted this question several times and no one could follow directtions. I have my code doing what is asked of the problem with the exception of displaying the last_name, first_name
A teacher is requiring her students to line up in alphabetical order, according to their first names..For example, in one class Chapel, Christine would be at the front and Uhura, Nyota would be last. The program will get the names from a file using getline since the file name includes spaces. The names should be read in until there is no more data to read.
The program should prompt the user for the file name and read the data from the file. Note that these names might include spaces; handle your input accordingly. The expected output is two names; do not show the entire file.
Do not use arrays or sorting for this problem.
Here is my code. What needs to be fixed so it will display last_name, first_name as formatted in the attachment?
How do I fix my code so that the program displays the student's full name? I have attached a screenshot of the code's current output as well as the list containing student's full names..Below is my code as it is currently written.
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
string fileName;
string name, front, end;
ifstream inputFile;
cout << "Student line up order";
cout << endl;
cout << "Please enter name of file containing the student line up: ";
getline(cin, fileName);
cout << endl;
inputFile.open(fileName);
if (!inputFile)
cout << "Error Opening File.\n";
else
{
inputFile >> name;
front = end = name;
while (!inputFile.eof())
{
if (name > end)
end = name;
if (name < front)
front = name;
inputFile >> name;
}
}
cout << endl << front << " is at the front of the line and "<< end << " is at the end of the line.";
cout << endl;
inputFile.close();
return 0;
}
![**Educational Context: Understanding Sequence and Order**
Text Example:
---
"Aaliyah is at the front of the line and Zee is at the end of the line."
---
This text demonstrates the concept of sequence and order, which is fundamental in understanding various educational topics such as language, mathematics, and logical reasoning. The sentence clearly identifies two positions in a lineup: Aaliyah at the front and Zee at the end, helping students visualize and comprehend the concept of positional ordering. Practice with such examples can aid in developing a clear sense of order and sequence in different contexts.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F20ef5b89-bdf5-4ebf-bc1c-34f412b810c9%2Faae90e01-2111-4847-82e2-998fd93e03b6%2Fm0uy63_processed.jpeg&w=3840&q=75)
![### List of Random Names
This list contains a variety of randomly selected names. This is suitable for educational purposes where random name generation is required, such as examples in programming, testing databases, or creating sample data for projects.
1. Thomas, Nora Ann
2. Macdonald, Elijah
3. Torres, Layla
4. Lynch, Hazel
5. Watson, Josiah
6. Reyes, Melanie Roxanne
7. Tomas, Mateo
8. Castro, Logan
9. McCarthy, Callie
10. Mercado, Miles
11. Williams, Hunter
12. Doyle, Paisley
13. O'Doherty, London
14. Ferrari, Carter Lee
15. Garcia, Zee
16. Morrison, Nevaeh
17. Kennedy, Dylan
18. Anderson, Carson
19. Tomas, David
20. Andrada, Lillian
21. Pedersen, Ivy
22. Wilson, Hailey
23. McCarthy, Stella
24. Salazar, Owen Richard
25. Johnson, Melanie Elizabeth
26. Jones, Adeline
27. Nilsen, Dominic
28. Robinson, Madison
29. Anderson, Lucy
This document has no graphs or diagrams. It is a straightforward text list of names, formatted in a readable manner for easy reference or copying into another application.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F20ef5b89-bdf5-4ebf-bc1c-34f412b810c9%2Faae90e01-2111-4847-82e2-998fd93e03b6%2Faw8c0l8_processed.jpeg&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)