Write a program that will convert names in the LAST NAME, FIRST NAME MI format t
ID: 3634872 • Letter: W
Question
Write a program that will convert names in the LAST NAME, FIRST NAME MI formatto FIRST NAME MI LAST NAME format. For example, given the name
Nixon, Richard M.
the program will convert it to:
Richard M. Nixon
You will read the names from a file and write the names to the console. The input file has
one name per line and the last line in the file has a ".". The program should read the input
filename from the user.
this is what i have so far.
// Include Section
#include <iostream>
#include <fstream>
// Main Program
int main ()
{
using namespace std;
// Output Odentification
cout << " In class # 11 by - Reuel Brumell - Reverse Names ";
//Variable Declarations
char filename; // opens the file names.txt
char names [100[; // array
int i =0; //
ifstream isfile; // input file stream
cout << " Enter the file you wish to print in reverse order:";
cin >> filename;
isfile.open("F://names.txt");
// checks if the file opening failed.
if (isfile.fail())
{
cout << " Input file opening failed.";
exit(1);
}
Explanation / Answer
#include #include #include #include #include using namespace std; const int listofnames = 350; // This is the number of spaces in the array. int getData(ifstream &fin, int array[]); // Here is the function that finds each piece of the array. //string getData(ifstream &fin, string array[]); This is what it SHOULD look like. void outputData(ofstream &fout, int array[], int numNames); // This is the output function. //void outputData(ofstream &fout, string array[], int numNames) Also what this one should look like //Please note, I'm only guessing right now as to what everything should be. int main() { ifstream fin; ofstream fout; fin.open("names.txt"); // I need to use "names.txt", to display each name as apart of the array. //fin.open("numbers.txt"); fout.open("backwards.txt"); if(fin.fail()) { cerr array[i]) // i++; // // return i; //} void outputData(ofstream &fout, int array[], int numNames) // This function (in int form) sends the output. { for(int i=0;iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.