subject
Computers and Technology, 01.12.2020 04:40 zara76

C++ please. How can I implement the function definition (where the comment block on definitions. cpp is)? I am using a three file format and have attached the three files (definitons. cpp, header. h, main. cpp). The definitons. cpp file is the ONLY file that needs modification.

DEFINITIONS. CPP

/*
Name: Daniel Olivares
Class: CptS 121, Fall 2020
Date: November 30, 2020
U7 Vector Participation 11-30 Starter Code
Description: This program solves a vectors practice problem
Notes:
*/

#include "header. h"

/
* Function: importPackagesLog ()
* Date Created: 11/27/20
* Date Last Modified: 11/27/20
* Description: This function reads a data set from an input file
* and stores each line of package data in a
* corresponding vector
* Input parameters: output parameter variables for names, sizes,
* and weights of packages
* Returns: N/A
* Pre: The input file contains a list name and one or more sets of
* package data consisting of recipient name, package size,
* and package weight
* Post: Each package data from the input file is now stored in a
* set of parallel vectors
/

//
// WRITE YOUR FUNCTION DEFINITION HERE
//

/
* Function: printPackageList ()
* Date Created: 11/27/20
* Date Last Modified: 11/27/20
* Description: This prints the contents of the package list read
* from file
* Input parameters: package list name, a vector of names, sizes,
* and weights of packages
* Returns: true if package list name is not an empty string and
* all vectors are the same size
* Pre: The input string and vectors are not empty (at least one
* item read from the input file)
* Post: Each package data is printed to the console output
/

bool printPackageList(string packagesListName, vector names, vector sizes, vector weights)
{
//If our list name is not an empty string and our vectors are the same size...
if (packagesListName. size() > 0 && (names. size() == sizes. size() && names. size() == weights. size()))
{
cout //need for console IO
#include //don't forget to include libraries if we are using their functions!
#include //need for file IO
#include //need for vectors
#include //need for fixed precision output

using namespace std;

//complete the definition for this prototype
void importPackagesLog(ifstream&, vector &, vector &, vector &);

bool printPackageList(string, vector , vector , vector );

#endif // !HEADER_H

MAIN. CPP

/*
Name: Daniel Olivares
Class: CptS 121, Fall 2020
Date: November 30, 2020
U7 Vector Participation 11-30 Starter Code
Description: This program solves a vectors practice problem
Notes: see inline comments
main cpp file -- should only contain our main() function!
only one include to the header file
*/

#include "header. h" //notice the include uses " --> this indicates this is a FILE PATH

int main() {
string inputFileName = "packages. log";
string line = "", packageListName = "";
bool readSuccess = false;

//These are three EMPTY vectors! They have NO size!
//We CANNOT access them using an index value while the are empty!
//We have to INCREASE their size when adding new items to our vector
//(hint: see vector member functions)
//We are using these as three PARALLEL vectors -- you should be familiar with this
//concept, if not, use this as a chance to ask for help or look it up! (hint it's important)
vector names;
vector sizes;
vector weights;

ifstream infile;
infile. open(inputFileName);

//test file is open
if (!infile. is_open())
{
cout << "Failed to open " << inputFileName << ". Exiting program." << endl;
return -1;
}

//read package list name
getline(infile, packageListName);
//get rid of the newline
getline(infile, line);

//Task: complete the function definition given the function prototype and function call
importPackagesLog(infile, names, sizes, weights);

readSuccess = printPackageList(packageListName, names, sizes, weights);

if (readSuccess)
cout << "Successfully read the packages list!" << endl;
else
cout << "Failed to read the packages list!" << endl;

return 0;
}

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 24.06.2019 13:30, iicekingmann
In the rgb model, which color is formed by combining the constituent colors? a) black b) brown c) yellow d) white e) blue
Answers: 1
image
Computers and Technology, 24.06.2019 18:10, albattatasraap5wymy
Most information security incidents will occur because of select one: a. users who do not follow secure computing practices and procedures b. increases in hacker skills and capabilities c. poorly designed network protection software d. increasing sophistication of computer viruses and worms
Answers: 1
image
Computers and Technology, 24.06.2019 18:20, bm42400
The following if statement contains a logic error, not a syntax error. rewrite it so that it is correct. assume the variable age already exists and holds a valid number. if (age == 18 & & age == 19) {
Answers: 1
image
Computers and Technology, 25.06.2019 01:30, 91miketaylor
The study of how to design software, solve problems such as computer security threats, or come up with better ways of handling data storage
Answers: 1
You know the right answer?
C++ please. How can I implement the function definition (where the comment block on definitions. cp...

Questions in other subjects:

Konu
Social Studies, 21.01.2021 01:00
Konu
Arts, 21.01.2021 01:00