Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

com/webapp/blackboard/content/listContentjspicourse id 260384 1&content.id-.1417

ID: 3752797 • Letter: C

Question



com/webapp/blackboard/content/listContentjspicourse id 260384 1&content.id-.14175795 18mode reset Attached Files Lab4Template bt (479 B) This assignment includes an "outline" of the program in the attached file You have to fill in many of the details This assignment is the first that contains Optional Challenges. Skipping t them will not lower your grade Completing them will not raise your grade. They are there in case you want to challenge yourself. Requirements 1 Prompt the user for the number of words to be entered 2 Use new to allocate an array of that number of std strings. What kind of pointer do you need? 3. Use a for loop to read in each word from the keyboard using gotline0. Ater the user enters a word, have your program automatically ADD A PERIOD AT THE END OF THE WORD This is called a "sentiner. A sentinel is a marker that can be used to indicate the end of data, in this case the end of the set of characters in the string 4 Atfter all the words have been entered, use a while loop nested in a for loop to count the number of characters in each word by counting characters until the sentnels reached 5 Display each word followed by the number of letters Optional Chalenge Compute and display the total number of letters across all words. Optionial Chailenge of allocating an array of strings, allocate an array of structs where each struct contains a string and a leter count Cheiblist 1 Uncheck the Create direatory for solution checkbox in the New Praject Dialog 2 Projectisolution named correctly 3 Correct comments at top 4 Consistent indentation (Use EditAdvanced/Format Document) 5 Good variable names 6 Overall neat organization Comments in cade explain whats being dofe For each new there should be la delete

Explanation / Answer

{

cout<<"Please enter ...";
cin>>numStrings;
string* words=new string[numStrings];
for(int i=0;i<numStrings;i++)
{
getline(cin,words[i],'.');
}
for(int n=0;n<numStrings;n++)
{
int count=0;
while(words[n][count]!='.')
{
count++;
}
cout<<words[n]<<" has "<<count<<" letters ";
}
delete []words;
}