Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

simple c++ code please Question 1: (File I/O with vector of doubles) An input file contains a list of numbers separated by spaces. Write the

image text in transcribed

simple c++ code please

Question 1: (File I/O with vector of doubles) An input file contains a list of numbers separated by spaces. Write the following functions: vector readValues(); void printResults(vector values); The readValues function should do the following steps: Open the input file "input.txt" and make sure it is opened successfully, if not print an error message and exit the program. Declare a vector to hold the values of type double, call it res. Read values from the file and save them into the vector res. Close the input file Return the vector res to the caller. . . Th printResults function should do the following steps: Open an output file called output.txt Declare and initialize variables for min, max and sum, make sure not to use a constant value (like 0) to initialize the min and max. Calculate min, max and sum. Print min max and sum to the output file. Write a C++ program that call readValues function to read the values from the file and return them into a vector call it values. Then call the printResults function to print the results an output file named output.txt. Sample input and output files are given below: output.txt input.txt + x Source.cpp 22.2 1.365 6 9.443 1.232 5.3 4.34 Source.cpp = output.txt + x input.txt Min 1.232 Max 22.2 Sum 49.88 = =

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

Recommended Textbook for

Database Processing

Authors: David M. Kroenke

12th Edition International Edition

1292023422, 978-1292023427

More Books

Students also viewed these Databases questions

Question

Show the properties and structure of allotropes of carbon.

Answered: 1 week ago

Question

4. What will the team agreement contain?

Answered: 1 week ago