Question: The feedback on my pseudo code was: Your pseudocode handles file reading well, but it should include a check to ensure all prerequisites exist as

The feedback on my pseudo code was:
"Your pseudocode handles file reading well, but it should include a check to ensure all prerequisites exist as keys in the hash table."
"TheCourseobject creation is clear, but you should specify how prerequisites are stored and address potential duplicatecourseNumberkeys."
"The print function is well-designed, but refining the handling of missing prerequisites and improving output formatting would enhance clarity."
Can you please help me adjust the pseudo code to accommodate the feedback?
Pseudocode
// Function to open and parse file, and load courses from file into a hash table
void loadCourses(Hashtable courses, String fileName){
OPEN file filename;
WHILE not end of file {
READ line;
SPLIT line by commas into tokens;
IF tokens.length <2{
PRINT "Error: Invalid format";
CONTINUE;
}
courseNumber = tokens[0];
name = tokens[1];
prerequisites = tokens[2 to end];
CREATE new Course object with courseNumber, name, and prerequisites;
ADD Course object to hash table with key = courseNumber;
}
CLOSE file
}
// Function to print course information and prerequisites
void printCourseInformation(Hashtable courses, String courseNumber){
IF course does not contain key courseNumber {
PRINT "Course not found";
RETURN;
}
course = courses[courseNumber];
PRINT "Course Number: "+ course.courseNumber;
PRINT "Name: "+ course.name;
IF course.prerequisites is empty {
PRINT "No prerequisites";
RETURN;
}
PRINT "Prerequisites:";
For each prerequisite in course.prerequisites:
IF courses contains key prerequisite {
prereqCourse = courses[prerequisite];
PRINT "-"+ prereqCourse.courseNumber +": "+ prereqCourse.name;
ELSE {
PRINT "- Missing prerequisite: "+ prerequisite;
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!