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

MIS
9th Edition
ISBN:9781337681919
Author:BIDGOLI
Publisher:BIDGOLI
Chapter9: Global Information Systems
Section: Chapter Questions
Problem 5RD
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;
}

Aaliyah is at the front of the line and Zee is at the end of the line.
Transcribed Image Text:Aaliyah is at the front of the line and Zee is at the end of the line.
Random names - Notepad
File Edit Format View Help
Thomas, Nora Ann
Macdonald, Elijah
Torres, Layla
Lynch, Hazel
Watson, Josiah
Reyes, Melanie Roxanne
Tomas, Mateo
Castro, Logan
McCarthy, Callie
Mercado, Miles
Williams, Hunter
Doyle, Paisley
O'Doherty, London
Ferrari, Carter Lee
Garcia, Zee
Morrison, Nevaeh
Kennedy, Dylan
Anderson, Carson
Tomas, David
Andrada, Lillian
Pedersen, Ivy
Wilson, Hailey
McCarthy, Stella
Salazar, Owen Richard
Johnson, Melanie Elizabeth
Jones, Adeline
Nilsen, Dominic
Robinson, Madison
Andanan
THAY
Transcribed Image Text:Random names - Notepad File Edit Format View Help Thomas, Nora Ann Macdonald, Elijah Torres, Layla Lynch, Hazel Watson, Josiah Reyes, Melanie Roxanne Tomas, Mateo Castro, Logan McCarthy, Callie Mercado, Miles Williams, Hunter Doyle, Paisley O'Doherty, London Ferrari, Carter Lee Garcia, Zee Morrison, Nevaeh Kennedy, Dylan Anderson, Carson Tomas, David Andrada, Lillian Pedersen, Ivy Wilson, Hailey McCarthy, Stella Salazar, Owen Richard Johnson, Melanie Elizabeth Jones, Adeline Nilsen, Dominic Robinson, Madison Andanan THAY
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
  • SEE MORE QUESTIONS
Recommended textbooks for you
MIS
MIS
Computer Science
ISBN:
9781337681919
Author:
BIDGOLI
Publisher:
Cengage
Np Ms Office 365/Excel 2016 I Ntermed
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning