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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

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.
Transcribed Image Text:**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.
### 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.
Transcribed Image Text:### 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.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Graphical User Interface
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education