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

basic c++ Can someone help with the below program in the simplest form possible

ID: 3573606 • Letter: B

Question

basic c++

Can someone help with the below program in the simplest form possible using only complex conditionals, for or while loops, functions, or arrays. We quickly learned about vectors so I'm not sure if that is what is required to get the below output?

Write a program that reads in names from stdin. Stop reading names when the name is "***DONE***". There will not be more than 100 names, although there may be way fewer. Next, display the second half of the list as shown below:

Reading: Charles

Reading: Debbie

Reading: Larry

Reading: Jerry

Reading: Elaine

Reading: Frank

Reading: George

Reading: Harry

Reading: Adam

Reading: Igor

Reading Betty Ann

Reading ***DONE***

There are 11 names in the list

Listing names 5 through 20

-> Frank

-> George

-> Harry

-> Adam

-> Igor

-> Betty Ann

Explanation / Answer

#include <iostream>

using namespace std;

int main()
{string str[100]; //declaring string array of size 100
cout << "Reading: "; //prompting user to enter string
cin>>str[0]; //storing user entered string into first index of string array
int i=0; //variable to keep track of the total number of strings entered by the user
//run the loop while user has not entered ***DONE***
while(str[i] != "***DONE***"){
i++;
cout << "Reading: "; //prompting user to enter string
cin>>str[i]; //storing user entered string into string array str
}
int count=i/2; //variable for printing second half i.e divide the total no.of elements by 2
cout<<"There are "<<i<<" names in the list"<<endl;
cout<<"Listing names "<<count<<" through "<< i<< endl;
//printing second half
for(int j=count;j<i;j++)
cout<<"-> "<<str[j]<<endl;
  

return 0;
}

/*********OUTPUT**********
Reading: Charles
Reading: Debbie
Reading: Larry
Reading: Jerry
Reading: Elaine
Reading: Frank
Reading: George
Reading: Harry
Reading: Adam
Reading: Igor
Reading Betty Ann
Reading ***DONE***
There are 11 names in the list
Listing names 5 through 11
Frank
->George
-> Harry
-> Adam
-> Igor
-> Betty Ann
*********OUTPUT***********/

/* Note: This code has been written in c++ and tested on g++ compiler,Please do ask in case of any doubt,Thanks */