A client with a completed main function is provided. The main function should not be modified. You must update the client by creating and implementing the various functions described below. readFile – Loads the parameter array with Billionaire objects. The data for each Billionaire is read from the given data file which is in CSV format (comma delimited - 1 line per record with fields separated by a comma.) The function should read each line from the file, pass the line read to the Billionaire class constructor and store the resulting object in the parameter array. The second parameter represents the maximum number of Billionaire objects that can be stored. displayAll - Displays a list of the Billionaires stored in the array. getRange – Determines the smallest wealth value and the largest wealth value within the array. These values are returned to the caller via reference parameters. getWealthiest – Returns the Billionaire within the array with the greatest wealth. getUS – Returns a count of the number of individuals in the array with United States citizenship. Hints: Start small and build on working code. Implement ONE function at a time, leaving the remaining code in the main commented out. Thoroughly test the function. Once you are satisfied with the result, move on to the next function. In the overloaded constructor of the Billionaire class, consider using a stringstream object. The third parameter of the getline function provides an option to specify a delimiter, allowing the getline function to extract one field at a time from the stringstream object. getline(iss,resultString,','); // iss is a istringstream object Only strings are read from a string stream. For integer and floating point values, the data must be converted after reading. Alternatively, the parameter string can be parsed using various methods of the string class. String class methods that you may find useful in parsing the data include find, erase, and substr. Don’t forget to include needed libraries! You may specify the std namespace either in the using clause or using scope resolution.
A client with a completed main function is provided. The main function should not be modified. You must update the client by creating and implementing the various functions described below.
- readFile – Loads the parameter array with Billionaire objects. The data for each Billionaire is read from the given data file which is in CSV format (comma delimited - 1 line per record with fields separated by a comma.) The function should read each line from the file, pass the line read to the Billionaire class constructor and store the resulting object in the parameter array. The second parameter represents the maximum number of Billionaire objects that can be stored.
- displayAll - Displays a list of the Billionaires stored in the array.
- getRange – Determines the smallest wealth value and the largest wealth value within the array. These values are returned to the caller via reference parameters.
- getWealthiest – Returns the Billionaire within the array with the greatest wealth.
- getUS – Returns a count of the number of individuals in the array with United States citizenship.
Hints: Start small and build on working code. Implement ONE function at a time, leaving the remaining code in the main commented out. Thoroughly test the function. Once you are satisfied with the result, move on to the next function.
In the overloaded constructor of the Billionaire class, consider using a stringstream object. The third parameter of the getline function provides an option to specify a delimiter, allowing the getline function to extract one field at a time from the stringstream object.
getline(iss,resultString,','); // iss is a istringstream object
Only strings are read from a string stream. For integer and floating point values, the data must be converted after reading.
Alternatively, the parameter string can be parsed using various methods of the string class. String class methods that you may find useful in parsing the data include find, erase, and substr.
Don’t forget to include needed libraries! You may specify the std namespace either in the using clause or using scope resolution.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 6 images