I need help with this program using c++ language!
CS 317
Program Assignment
Name Arrange
You are to write a program that will read in each person’s name and print out the results. The list has been collected form different places and the names are not in some standard format. A person’s last name may appear last or it may appear first. A label has been associated with each name to identify where the last name appears. Either “surname” or “lastname” appears just before a person’s last name. The other will be his first name followed by optionally middle initial or name. Capitalize the first letters of each part of a name. Examples of inputs are given below.
Read in the names, and arrange them with the last name first, followed by a comma, followed by the first name and his middle name or initial if it exist.
Input file: namesLast.txt
Example input
tom archer lastname jones
lastname luewey Huewey dewy
See More surname Or-less
Example output (Sorted):
Jones, Tom Archer
Luewey, Huewey Dewy
Or-less, See More
This is the data input file: namesLat.txt
lastname Taylor marie denise james wilis surname thomas Stone Rock lastname Brown surname lea high lee stephens jabcobs lastname reynolds lastname russell mack hussell surname Lewis Michelle Tee john mark surname marshall lastname Moto ah sey o e lastname vey Twosee ore surname knocktosee surname finitee two N lastname ghigher Eve N T tow surname jammer Uh nuther lastname one surname Lotts lue Knew Ah C lastname moto lastname phinshed Just about Thee last surname own
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <cstdlib>
#include <string>
using namespace std;
// function prototype
string capitalizeWord(string);
int main()
{
vector<string> names;
string line;
ifstream inFile("namesLat.txt");
if(!inFile.is_open())
{
cout << "Error in opening namesLat.txt" << endl;
exit(0);
}
while(getline(inFile, line))
{
stringstream ss(line);
vector<string> tokens;
string token;
// read each line from file
while(getline(ss, token, ' '))
{
tokens.push_back(token);
}
// capitalize all the tokens
for(int i = 0; i < tokens.size(); i++)
{
tokens[i] = capitalizeWord(tokens[i]);
}
// search for the word "Lastname" or "Surname"
// the index of the next word is the surname
string surname = "";
for(int i = 0; i < tokens.size(); i++)
{
if(tokens[i].compare("Lastname") == 0 || tokens[i].compare("Surname") == 0)
{
surname = tokens[i + 1];
// set surname index and after index equal to ""
tokens[i] = "";
tokens[i + 1] = "";
}
}
// using a for loop, append all the tokens which are not blank
// to construct the firstname and middlename (if any)
stringstream resStream;
string result = "";
for(string s : tokens)
{
if(s.compare("") != 0)
{
resStream << s << " ";
}
}
// finally, add the surname before the name to finalise the name
result = surname + ", " + resStream.str();
// add the full name to the list of names
names.push_back(result);
}
// finally, print all the names from the list
cout << "All names:\n";
for(string name : names)
{
cout << name << endl;
}
return 0;
}
// this method returns a capitalised version of the input string "s"
string capitalizeWord(string s)
{
s[0] = toupper(s[0]);
return s;
}
***************************************************************** SCREENSHOT **********************************************************

I need help with this program using c++ language! CS 317 Program Assignment Name Arrange You...
Do WITHOUT #include<sstream> C++ You are to write a program that will read in upto 15 names, rearrange each person's name. The list has been collected from different places and the names are not in some standard format. A person's last name may appear last or it may appeaer first. A label has been associated with each name to identify where the last name appears. Either "surname" or "lastname" appears just before a person's last name. The other will be...
Please help me with this program.You are to write a C++ program that will read in up to 15 students with student information and grades. Your program will compute an average and print out certain reports. Format: The information for each student is on separate lines of input. The first data will be the student�s ID number, next line is the students name, next the students classification, and the last line are the 10 grades where the last grade is...
C++. You are to write a program to set up a data base for a phone index. The key will be a person’s name and the table will supply the phone number. The data base must be implemented as a hash table with the names as the key. The format will be a person name (multiple parts) followed by a phone number. Example: John Doe 601-5433 or O E Vay 921-1234. Only one name one phone number will be on...
need help on C++ Discussion: The program should utilize 3 files. player.txt – Player name data file – It has: player ID, player first name, middle initial, last name soccer.txt – Player information file – It has: player ID, goals scored, number of penalties, jersey number output file - formatted according to the example provided later in this assignment a) Define a struct to hold the information for a person storing first name, middle initial, and last name). b) Define...
This is Visual Basic program, thank you for your help In this assignment, you'll start a new Windows Forms application. Assume we have the data shown below: Names_first={"jack","marjy","tom","luke","sam","al","joe","miky","lu"} Name_last={"jones","ety","fan","spence","amin",sid","bud","ant","ben"} Amounts={234.45,8293.1,943.25,27381.0,271.39,7436.12,2743.0,1639.95,2354.2} The above will allows us to emulate reading data from a file, which we will learn in the next unit. For now, we will assume the data above has been read from a file. We need to process this data in fast way. For that purpose, we need to: Declare...
//I NEED THE PROGRAM IN C LANGUAGE!// QUESTION: I need you to write a program which manipulates text from an input file using the string library. Your program will accept command line arguments for the input and output file names as well as a list of blacklisted words. There are two major features in this programming: 1. Given an input file with text and a list of words, find and replace every use of these blacklisted words with the string...
C++ I need a program that will read a list of names from a data file and store them in an array. You will then sort the array by last name using a quicksort, and display the results, one name per line.Each line has a first name and a last name.The file has 40 names in it right now, but the array should be able to accommodate up to 50 names.txt***************************************************** Barbara Wright Ian Chesterton Steven Taylor Sara Kingdom Dodo...
Please help. I need a very simple code. For a CS 1 class. Write a program in Java and run it in BlueJ according to the following specifications: The program reads a text file with student records (first name, last name and grade). Then it prompts the user to enter a command, executes the command and loops. The commands are the following: "printall" - prints all student records (first name, last name, grade). "firstname name" - prints all students with...
I need help programming this question using C language. This program uses input data entered in command line at the same time when the command or .exe file is entered. They are called command-line arguments. Because everything entered in command line is taken as a string, these arguments including the command itself or the .exe file name are stored in an array of char pointers, each pointer points to the first character of a string (i.e., argument). The inputs can...
Create a class named Module2. You should submit your source code file (Module2.java). The Module2 class should contain the following data fields and methods (note that all data and methods are for objects unless specified as being for the entire class) Data fields: A String object named firstName A String object named middleName A String object name lastName Methods: A Module2 constructor method that accepts no parameters and initializes the data fields from 1) to empty Strings (e.g., firstName =...