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

1) Write a code snippet which asks the user to enter city names until \"DONE\" i

ID: 3860622 • Letter: 1

Question

1) Write a code snippet which asks the user to enter city names until "DONE" is entered and stores the cities entered in a string vector.
Then print the cities that were entered but in reverse order.

2) Write a function printAll which takes as a parameter a vector of Point2D objects and prints all their locations. The function returns nothing.

3) Write a function moveAll that takes as a parameter a vector of Point2D objects, and two int parameters moveX and moveY and moves all the points by moveX and moveY. The function returns nothing.
Create a vector of points in the main and add 3 points to it. Call the function to move all the points by -2, 5. Then, call the printAll function and verify that they have moved.

4) Write a function combine which takes two vectors of student names, group1 and group2 and returns a vector containing all the students in both groups.
Call your function from the main with two groups you create and then print the result returned from the function.

5) Describe briefly how vectors are like arrays and how they are more powerful than arrays.

Explanation / Answer

Answer of the first question , As per Chegg GuideLines please ask other questions as seperate questions .

Here in this questions we have used while loop to run infinitely and inside that if constrain is put to check if "DONE" is entered and it will break if "DONE" is entered

#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main()
{
vector <string> g1;
string city ;
do{
cin >> city;
if(city == "DONE"){
break;
}
g1.push_back(city);
}
while(true);
for(int i=g1.size()-1; i >= 0; i--){
cout << g1[i] << " ";
}

return 0;
}