Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions 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;
}

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.]
expand button
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
Check Mark
Knowledge Booster
Background pattern image
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
    Text book image
    Database System Concepts
    Computer Science
    ISBN:9780078022159
    Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
    Publisher:McGraw-Hill Education
    Text book image
    Starting Out with Python (4th Edition)
    Computer Science
    ISBN:9780134444321
    Author:Tony Gaddis
    Publisher:PEARSON
    Text book image
    Digital Fundamentals (11th Edition)
    Computer Science
    ISBN:9780132737968
    Author:Thomas L. Floyd
    Publisher:PEARSON
    Text book image
    C How to Program (8th Edition)
    Computer Science
    ISBN:9780133976892
    Author:Paul J. Deitel, Harvey Deitel
    Publisher:PEARSON
    Text book image
    Database Systems: Design, Implementation, & Manag...
    Computer Science
    ISBN:9781337627900
    Author:Carlos Coronel, Steven Morris
    Publisher:Cengage Learning
    Text book image
    Programmable Logic Controllers
    Computer Science
    ISBN:9780073373843
    Author:Frank D. Petruzella
    Publisher:McGraw-Hill Education