I am having trouble with these 2 review questions for my C++ course.
Ex 9: Storing an array into a file.
a) Implement the integer array {1,2,3,4,5}.
b) Implement a save function which stores the array into a file using comma delimited format (1,2,3,4,5).
Example File
1,2,3,4,5,
Ex 10: Reading an array into a file.
a) Implement a partially filled integer array of size 100.
b) Implement a load function which:
1) Reads the input file (from problem 9) one line at a time.
2) Parses each line using stringstream into tokens (comma delimiter).
3) Converts each token into an integer then stores each token into the array.
c) Implement an output function that outputs the array to the console.
Example Output (from file to the array, to console)
1 2 3 4 5
Step by stepSolved in 2 steps
- I/ implement copyToVec such that: // 1) receives three parameters, an array, the array's size, and a vector // 2) copy elements from the array to the vector. Copy elements from 0 to size-1 // 3) using the RANGE-BASED for Loop ONLY, add 0.9 to every element in the vector /* implement main such that: 1) crate an array of size 100 and type float 2) prompt the user to enter 50 values 3) create a new instance of type vector that can store float values 4) invoke copyVec using this exact statement: copyToVec(arrFloat, 30, vecFloat); 5) Using the RANGE-BASED for Loop. print the values from the vector such that that the output is formatted as shown below. Use the following input test data: 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 vecFloat[0] vecFloat[1] = 1.290e+01 vecFloat[2] vecFloat[3] vecFloat[4] vecFloat[5] = 1.690e+01 vecFloat[6] = 1.790e+01 vecFloat[7] vecFloat[8] = 1.990e+01…arrow_forwardWrite three functions for: mean, remove, display //include any standard libraries needed // - passes in an array along with the size of the array // - returns the mean of all values stored in the array double mean( const double array [ ], int arraySize); // - Passes in an array, the size of the array by reference, and the index of a value to be removed from the array. // - Removes the value at this index by shifting all of the values after this value up, keeping the same relative order of all values not removed. // - Refuces arraySize by 1. void remove (double array[], not &arraySize, int index); // - Passes in an array and the size of the array. // - outputs each value in the array separated by a comma and space, with mo comma, space or beeline at the end. void display (const double array[], int arraySize); const int ARR_CAP = 100; int main (int argc, char *argv[]){// verify file name provided on command line // open file and verify it opened // declare an array of doubles of…arrow_forward1- Write a user-defined function that accepts an array of integers. The function should generate the percentage each value in the array is of the total of all array values. Store the % value in another array. That array should also be declared as a formal parameter of the function. 2- In the main function, create a prompt that asks the user for inputs to the array. Ask the user to enter up to 20 values, and type -1 when done. (-1 is the sentinel value). It marks the end of the array. A user can put in any number of variables up to 20 (20 is the size of the array, it could be partially filled). 3- Display a table like the following example, showing each data value and what percentage each value is of the total of all array values. Do this by invoking the function in part 1.arrow_forward
- # dates and times with lubridateinstall.packages("nycflights13") library(tidyverse)library(lubridate)library(nycflights13) Qustion: Create a function called date_quarter that accepts any vector of dates as its input and then returns the corresponding quarter for each date Examples: “2019-01-01” should return “Q1” “2011-05-23” should return “Q2” “1978-09-30” should return “Q3” Etc. Use the flight's data set from the nycflights13 package to test your function by creating a new column called quarter using mutate()arrow_forwardC++ I cannot run the code. Please help me fix it. Below is the requirement of the code. Design and write a C++ class that reads text, binary and csv files. The class functions: Size: Returns the file sizeName: Returns the file nameRaw: Returns the unparsed raw data (use vector here to get the unparsed raw data)Parse: A external function to Parse the data. The function accepts the raw data and returns the data parsed by the function. This type of function is called a "Call-Back Function". A Call-Back is necessary for each file as each file requires different regular expressions to parse. With binary files, need to use RegEx to do the parse(). [My code doesn't have this part] Please refer to the Callback.cpp example on how to setup a Call-Back. CallBack.cpp: #include <string>#include <functional>#include <iostream>#include <vector>using namespace std; string ToLower(string s){ string temp; for (char c : s)…arrow_forwardC++ Question Hello Please answer the attached C++ programming question correctly, just as the prompt states. Also, make sure that the code is working properly. Thank you.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education