Related questions
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;
}
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 2 images
- Python question please include all steps and screenshot of code. Also please provide a docstring, and comments throughout the code, and test the given examples below. Thanks. Write a function called honorRoll(). Its only input parameter is a list that contains listsconsisting of a name followed by a series of grades (integers). All grades will be in therange 0-100. All students will have at least one grade, but not all students will have thesame number of grades. Your function should return a list of students whose averagegrade is above 92.0.>>> honorRoll([['Alice', 95, 92, 98], ['Carlos', 85, 87, 95, 91], ['Betty', 81, 74, 89]])['Alice']>>> honorRoll([['Alice', 92, 92, 92], ['Bob', 81, 46]])[]arrow_forwardWrite a function called findavg that takes a pointer to a struct student as inputand will return the average of the test scores in their list. Use the const keyword ifapplicable. Any help would be appreciated!arrow_forward2. Write down the object for the operation: 3H*2-2H. Use the opcode provided in Table-I. TABLE I: OPCODE FOR QUESTION- 2 Mnemonics Opcode LDA 0011 ADD 0000 SUB 0010 OUT 1100 HLT 1111arrow_forward
- Write a program that animates the linear search algorithm. Create a list that consists of 20 distinct numbers from 1 to 20 in a random order. The elements are displayed in a histogram, as shown in Figure 10.17. You need to enter a search key in the text field. Clicking the Step button causes the program to perform one comparison in the algorithm and repaints the histogram with a bar indicating the search position. When the algorithm is finished, display a dialog box to inform the user. Clicking the Reset button creates a new random list for a new start.arrow_forwardPlease help (on jupyter note in python) Homecoming Shopping ListWe bought the following souvenirs for homecoming gathering: 5 shirts ( $ 10/item), $ 10 Polo Shirts ( $ 20.75/item), 5 trousers ( $ 29.95/item), 10 caps ( $ 11.95/item), 20 pens ( $ 1.99/item), 20 hoodies ( $ 24.95/item), and 30 chocoloates ( $ 2.95/item). Use Dot Product and NumPy arrays to compute the total cost of Homecoming.arrow_forwardWe know that the size of the previous question's struct point_st is 8 bytes. In general, what are the size and alignment rules for a struct?arrow_forward
- This solution does not work for the question asked. The question submitted clearly shows 2 list boxes on form 1. Is there an updated code?arrow_forwardThis is the questions and answers for the first parts Questions: Using Python Create a list with building names 'Richard Weeks Hall’, ’Busch Student Center’, ‘Environmental & Natural Resource Sciences Building’ Replace the list to 'Richard Weeks’, ’Busch Student Center’, ‘Environmental & Natural Resource Sciences Bldg’ Code for the total points of each name by setting• The base points as the length of the building name.• The bonus points: as ‘Bldg’ being equal to 10 points Meaning, 'Academic Building' which would be 'Academic Bldg' would have a base point of 13 and a bonus point of 10 for a total of 23. #1 Create a list of buildings Buildings=[ 'Richard Weeks Hall', 'Busch Student Center', 'Environmental & Natural Resource Sciences Building' ] print("The Building names in the list are: ") print(Buildings) #2 Process the name of each building res = [sub.replace(' Hall', '').replace('Building', 'Bldg') for sub in Buildings] print("The names have been replaced to :...arrow_forward
- Text book imageDatabase System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationText book imageStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONText book imageDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- Text book imageC How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONText book imageDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningText book imageProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education