Vectors are like arrays, but with a few additional features. Most importantly, they
can grow dynamically in an efficient way. Write a program that asks the user to
repeatedly enter positive integers and stop when the user enters -1.
You need to use a vector for this task. At the beginning of the program, the vector is empty. Then as the user enters values, the vector will be updated based on the following conditions in this order:
If the vector is empty, insert the user input value into the vector If the vector is not empty and the user input value is divisible by 5, then remove an element from the front of the vector. Don't insert the input in
vector.
If the vector is not empty and the user input value is divisible by 3, then remove an element from the end of the vector. Don't insert the input in
vector. Otherwise, insert the user input value at the end of the vector
Note that for a particular user input: once you find a condition is true, you should not evaluate the other conditions that follow.
After the user is done entering values, your program should display all elements in the vector, in order, separated by spaces. On the next line, print the sum of all the available elements in the vector.
Sample run (input is in bold)
Please enter a number: 3 Please enter a number: 4 Please enter a number: 7 Please enter a number: 5 Please enter a number: 8 Please enter a number: l0 Please enter a number: -1 The elements in the vector are: 7 8 Sum = 15