Question: #include #include #include using namespace std; / / * * complete readNames here to read in hw 1 input.txt into the matrix 3 x 4
#include
#include
#include
using namespace std;
complete readNames here to read in hwinput.txt into the matrix x
Purpose of the function:
Parameters are for: a x string matrix and the input stream to use
void readNamesstring N
note that you need to use a while loop because you do not know
how many lines are in the file, but you may assume that no bad row or column
numbers will be given
end of readNames
complete displayNames here to display what is in the matrix x
make sure it looks nice like a table
Purpose of the function:
Parameter are for: a x string matrix
void displayNamesstring N
end of displayNames
Create a search function that will allow you to look for a user inputted name
inside the matrix and output the indices of where it was located or or the message
"name was not found"
ask for the name in the main and pass to the function
Purpose of the function:
Parameters are for:
search
end of search
create a function that will find the longest name in the matrix
in cases where there are multiple names with the same longest length, you only
have to show the first one witht he longest length.
Purpose of the function:
Parameter are for:
findLongestName
end of findLongestName
The driver
int main
string Names; matrix of names
here initialize all slots as blank strings
string fname; the input file name
cout "Enter the input file name: ;
cin fname;
here create the stream fin to the file and open it
readNamesNames fin; reads
displayNamesNames; displays
end of main
Initialize the Names matrix with blank strings.
Get the filename from the user and send the stream to the readNames function.
Each line of the input file says the row and column first before the name. Rows are
always given as abc and columns are always given as abcd You do
not know how many lines are in the input file.
Make sure the matrix is displayed nicely like a table.
Create the function search. Call search twice in the main, one with a name from the
file and one without. Your function should work for both.
Create a function called findLongestName and have it display the longest name in the input file provided the screenshot
a a Mary
a c John
b a Kathy
b b Steve
c b Sue
c d David
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
