Question: The feedback on my pseudo code was: Your search and print logic is clear and straightforward. Enhance it by ensuring Error: Course not found is
The feedback on my pseudo code was:
"Your search and print logic is clear and straightforward. Enhance it by ensuring Error: Course not found is only printed after all iterations are complete."
"You effectively created and assigned attributes to the course object. Clarify how CreateCourseObject works to improve understanding of object instantiation."
Can you please help me adjust it to accommodate this feedback?
Pseudocode for Loading Data from File:
OPEN file at directory;
IF file is not found
PRINT "Error: File not found";
EXIT program;
For each line in file:
IF FUNCTION ValidLine
PROCEDURE DelimitedLine;
ELSE
PRINT "Error: Invalid line format";
CLOSE file;
Function ValidLine:
VALIDATE if the line has at least two parameters;
tokens Splitline;
IF Lengthtokens
RETURN True;
ELSE
RETURN false;
Procedure DelimitedLine:
EXTRACT course information from line;
tokens Splitline;
courseNumber tokens;
name tokens;
prerequisites tokens: ;
For each prerequisite in prerequisites:
IF not FUNCTION CourseExists
PRINT "Error: Prerequisite not valid for courseNumber;
EXIT program;
CREATE course object and store in vector data structure;
courseObject CreateCourseObjectcourseNumber name, prerequisites
VectorAppendcourseVector courseObject
Function CourseExists:
VALIDATE if courseNumber exists in the vector
For each course in courseVector:
IF course.courseNumber courseNumber
RETURN True;
ELSE
RETURN False;
Pseudocode for Creating Course Objects and Storing in Vector:
CREATE a new course object;
newCourse new CourseObject;
SET instance variables with data;
newCourse.courseNumber courseNumber;
newCourse.courseTitle name;
newCourse.prerequisites prerequisites;
RETURN newCourse;
APPEND an element to the end of the vector;
vectorlengthvector element;
Pseudocode for Searching and Printing Course Information:
For each course in courseVector:
WHILE not at the last line
IF course.courseNumber courseNumber
PRINT "Course Number: course.courseNumber;
PRINT "Course Name: course.name;
PRINT "Prerequisites: course.prerequisites;
RETURN;
ELSE
PRINT "Error: Course not found"
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
