Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

DO NOT USE CHATGPT In this Programming Exercise you will write a C + + program that does the following: Prompt the user to identify

DO NOT USE CHATGPT
In this Programming Exercise you will write a C++ program that does the
following:
Prompt the user to identify a file containing integer values, one value in each
record.
Create a vector that can be used to store integer (int) values.
Read the values from the file and store them in the vector.
Close the file.
Display the number of elements in the vector as well as all the even values in
the vector.
Remove the elements in the vector that contain even values.
Display the number of elements that were deleted.
Display the number of elements in the vector as well as all the odd values in
the vector.
Calculate and display the total of all values remaining in the vector.
Sample Output:
Identify the file containing initial values: D:/Data/vinput.txt
7 even entries removed.
Size is 8, odd values: 13579111315
Total is 64
You must solve this problem using only the material that has been presented
so far in the course. At this point, we have covered Chapters 1 through 7.
Hint: Methods named erase () and begin (), which are not
mentioned in our textbook, can be used to delete a specific
element from a vector. For example, to delete the third element
from a vector named numbers, you would use the following
statement:
numbers.erase (numbers.begin ()+2;
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions