Activities Define a struct called Unit containing the following fields I Unit code Unit credit hours Unit semester of study L
pluginfile.php/94428/mod resource/content/1/lab %202 %20 %28file %20and%20parsing % 29.pdf Expected C++ Skills to finish this Activities Define a struct called Unit containing the following fields I Unit code Unit credit hours Unit semester of study List of prerequisites Number of prerequisites List of post requisites Number of post requisites Inside your main function declare an array of type Unit called units with size 20 elements. This array will contain the information related to all the units in our diploma program. Each of the elements of this array correspond with one our diploma units. II III Inside your main function define a string named sample. This string will be used to read information from a file and then parse the information into the elements of the array units []. IV. Create and ifstream object, and then open the input file “diloma-flowchart.txt” Read each line of the input file into the string sample. The organization of each line is given as the example below V. “15FELE120;3;2; 15FELE111; 15FELE210,15FELE 214;” This string contains the following information 15FELE120: it is the unit code followed by a; (semicolon) to indicate the end of the unit code 3: mumber of credit hours followed by the ; (semicolon) to indicate the end of credit hours 2: semester of study followed by the; (semicolon) to indicate the end of semester of study 15FELE111: prerequisite followed by; to indicate end of prerequisites, if there were more than 1 prerequisite, then the values would be separate by a, (comma) 15FELE210,15FELE214: list of post-requisites separated with , (comma) then followed by; to indicate the end of the list VI Write a program to extract the above information from the sample string and then fill out the corresponding fields inside the fields of the array units []. In the end, write all the information contained inside the array units [], on the output. pluginfile.php/94428/mod resource/content/1/lab %202 %20 %28file %20and%20parsing % 29.pdf Expected C++ Skills to finish this activity Simple data types C++ structs C++ string class Conversion of string to values C++ arrays C++ loops C++ branching C++ in/output Background use in this lab, will help you in The skills that you accomplishing your final project. So, it is very useful if you give it enough attention and time In the previous lab you learned how to use C++ struct to define and work with complex data structures. In fact structs are the first step to the world of object oriented programming, wherein everything is treated as a standalone object with a mumber of attributes (like the ones you create for sstruct) and routines (which is missing from the struct). In this lab, you will read information from a file line by line and then parse the strings that contain multiple information relating to a unit including the unit code, credit hours, semester of the unit, a list of prerequisites, and a list of post-requisite units. You need to extract all this information and then store it inside a struct. For this activity you need to get comfortable with some of the useful string data type functions. Therefore, I would suggest you review the string class in C++ and some of its useful functions from the following linke http://www.cplusplus.com/reference/string/string/Pkwstring You also need to learn to work with files, you can find a link quick review of file operation in the following http://www.cplusplus.com/doc/tutorial/files/ 1/2



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *