Q10) implement the following C++ program which includes the following members: 1) Implement the function readFile as follows: a. The function accepts one parameter of type vector. The vector will store double data types. b. The function reads the content of the file InputData. txt and add them to the vector parameter. c. The function returns true if all values were successfully added to the vector. Otherwise, return false. 2) Implement the function position0f as follows: a. The function accepts two parameters, a constant vector parameter and a parameter of type double (called searchFor). b. The function returns the position of searchFor in the vector. If the value is not found, return -1. For example, if the value of searchFor is at the beginning of the vector, the function returns 0. If it is in the second position, the functions returns 1 ... 3) Write a main function as follows Invoke the function readFile. If the function returns true, continue to the next step, otherwise print an error message and terminate the program. b. Invoke the function position0f. Use the vector from the previous step and search for the value 37.89. Print the retuned result. Hint: this function call should returns 16. c. Invoke the function position0f once more and search for the value 10.01. Print the retuned result. Hint: this function call should returns -1. d. Copy the data from the vector into an array of size 30. If the value in the vector is negative, change it positive then add it to the array. The final version of the array should only contain positive numbers. а.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%
Q10) implement the following C++ program which includes the following members:
1) Implement the function readFile as follows:
a. The function accepts one parameter of type vector. The vector will store double data types.
b. The function reads the content of the file InputData. txt and add them to the vector parameter.
The function returns true if all values were successfully added to the vector. Otherwise, return false.
с.
2) Implement the function position0f as follows:
The function accepts two parameters, a constant vector parameter and a parameter of type double (called
searchFor).
а.
b. The function returns the position of searchFor in the vector. If the value is not found, return -1. For
example, if the value of searchFor is at the beginning of the vector, the function returns 0. If it is in the
second position, the functions returns 1 ...
3) Write a main function as follows
a. Invoke the function readFile. If the function returns true, continue to the next step, otherwise print an error
message and terminate the program.
b. Invoke the function position0f. Use the vector from the previous step and search for the value 37.89. Print
the retuned result. Hint: this function call should returns 16.
Invoke the function position0f once more and search for the value 10.01. Print the retuned result. Hint: this
function call should returns -1.
d. Copy the data from the vector into an array of size 30. If the value in the vector is negative, change it
positive then add it to the array. The final version of the array should only contain positive numbers.
c.
Transcribed Image Text:Q10) implement the following C++ program which includes the following members: 1) Implement the function readFile as follows: a. The function accepts one parameter of type vector. The vector will store double data types. b. The function reads the content of the file InputData. txt and add them to the vector parameter. The function returns true if all values were successfully added to the vector. Otherwise, return false. с. 2) Implement the function position0f as follows: The function accepts two parameters, a constant vector parameter and a parameter of type double (called searchFor). а. b. The function returns the position of searchFor in the vector. If the value is not found, return -1. For example, if the value of searchFor is at the beginning of the vector, the function returns 0. If it is in the second position, the functions returns 1 ... 3) Write a main function as follows a. Invoke the function readFile. If the function returns true, continue to the next step, otherwise print an error message and terminate the program. b. Invoke the function position0f. Use the vector from the previous step and search for the value 37.89. Print the retuned result. Hint: this function call should returns 16. Invoke the function position0f once more and search for the value 10.01. Print the retuned result. Hint: this function call should returns -1. d. Copy the data from the vector into an array of size 30. If the value in the vector is negative, change it positive then add it to the array. The final version of the array should only contain positive numbers. c.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education