Question

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
0 0
Add a comment Improve this question Transcribed image text
Answer #1

1. Define Structure UNIT as described in the list:

struct unit{
char code[10];
int numberOfCreditHours;
int semester;
int numberOfPreReq;
// pointer to number of pre-requisites
// eg:like char preRequisite[numberOfPreReq][10];
char* preReq;
int numberOfPostReq;
// pointer to number of post-requisites
// eg:like char postRequisite[numberOfPostReq][10];
char* postReq;
};

NOTE: this is a BIG question and has to be asked seperately, answering only one question here.

Add a comment
Know the answer?
Add Answer to:
Activities Define a struct called Unit containing the following fields I Unit code Unit credit hours...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 1. Define Structure UNIT as described in the list: ınit char codease complete the question int...

    1. Define Structure UNIT as described in the list: ınit char codease complete the question int numberOfCreditHours int semester int numberOfPreReq; pointer to number of pre-requisites eg:like char preRequisite[numberOfPreReq][10]; char* preReq int numberOfPostReq; pointer to number of post-requisites eg:like char postRequisite[numberOfPostReq] [1 0]; char* postReq NOTE: this is a BIG question and has to be asked seperately, answering only one question here. pluginfile.php/94428/mod resource/content/1/lab 6202 %20 %28file %20and%20parsing % 29.pdf Expected C++Skills to finish this activity Simple data types C++...

  • IN C ONLY As mentioned earlier there are two changes we are going to make from...

    IN C ONLY As mentioned earlier there are two changes we are going to make from lab 5, The file you read into data structures can be any length. studentInfo array will be stored in another struct called studentList that will contain the Student pointer and current length of the list. Sometimes data can be used in structs that correlate between variables so it's convenient to store the data in the same struct. Instead of tracking a length variable all...

  • Hello! I'm posting this program that is partially completed if someone can help me out, I...

    Hello! I'm posting this program that is partially completed if someone can help me out, I will give you a good rating! Thanks, // You are given a partially completed program that creates a list of employees, like employees' record. // Each record has this information: employee's name, supervisors's name, department of the employee, room number. // The struct 'employeeRecord' holds information of one employee. Department is enum type. // An array of structs called 'list' is made to hold...

  • I need help regarding my Visual Basic code ISC/ITE 285 Homework Due: Monday, January 28 by...

    I need help regarding my Visual Basic code ISC/ITE 285 Homework Due: Monday, January 28 by 11:55 pm Create a text file named "Grades.txt" which will contain a list of numeric grades. Save the file in the projects Bin/Debug folder. A sample of the file contents is shown below: 80 96 95 86 54 97 Create a string array that will be populated from the file "Grades.txt" when the array is created (Class-level array). Also create a numeric array that...

  • // Write the compiler used: Visual studio // READ BEFORE YOU START: // You are given...

    // Write the compiler used: Visual studio // READ BEFORE YOU START: // You are given a partially completed program that creates a list of patients, like patients' record. // Each record has this information: patient's name, doctor's name, critical level of patient, room number. // The struct 'patientRecord' holds information of one patient. Critical level is enum type. // An array of structs called 'list' is made to hold the list of patients. // To begin, you should trace...

  • DO NOT use #include <cstdlib> , iterate, and list. USE pointers and arrays. 1.Define a class...

    DO NOT use #include <cstdlib> , iterate, and list. USE pointers and arrays. 1.Define a class named Family in a header file named: family.h (5 points) This file acts as a prototype. 2.Create the implementation file family.cpp (15 points total) a.The class will have the following members 1.Family name (5 points) 2. Parent (array of 2) (5 points) a.First Name b.Last Name c. Age (you must validate the age is the proper data type. You can use the code from...

  • Need this in C The starter code is long, if you know how to do it...

    Need this in C The starter code is long, if you know how to do it in other way please do. Do the best you can please. Here's the starter code: // ----------------------------------------------------------------------- // monsterdb.c // ----------------------------------------------------------------------- #include #include #include // ----------------------------------------------------------------------- // Some defines #define NAME_MAX 64 #define BUFFER_MAX 256 // ----------------------------------------------------------------------- // Structs typedef struct { char name[NAME_MAX]; int hp; int attackPower; int armor; } Character; typedef struct { int size; Character *list; } CharacterContainer; // ----------------------------------------------------------------------- //...

  • The following code uses a Scanner object to read a text file called dogYears.txt. Notice that...

    The following code uses a Scanner object to read a text file called dogYears.txt. Notice that each line of this file contains a dog's name followed by an age. The program then outputs this data to the console. The output looks like this: Tippy 2 Rex 7 Desdemona 5 1. Your task is to use the Scanner methods that will initialize the variables name1, name2, name3, age1, age2, age3 so that the execution of the three println statements below will...

  • C++ i want Lab#3 done can u make clear code so I could understand it. Lab#2The...

    C++ i want Lab#3 done can u make clear code so I could understand it. Lab#2The objective of this lab is compare the populations of various cities that lie in between Toledo and Dayton on I-75. Write a program that produces a bar illustrating the populations. The program should read the name of the city and its population from a file. Have the program continue this process until the end of file is reached. For each city, your program should...

  • I need help writing this code for java class. Starter file: Project3.java and input file: dictionary.txt...

    I need help writing this code for java class. Starter file: Project3.java and input file: dictionary.txt Project#3 is an extension of the concepts and tasks of Lab#3. You will again read the dictionary file and resize the array as needed to store the words. Project#3 will require you to update a frequency counter of word lengths every time a word is read from the dictionary into the wordList. When your program is finished this histogram array will contain the following:...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT