Question
CSE 1384 - Vectors and Functions Lab 3 Objectives: Continue practicing past concepts Practice using vectors Practice using functions Assignment: Create a program that allows
CSE 1384 - Vectors and Functions Lab 3 Objectives: Continue practicing past concepts Practice using vectors Practice using functions Assignment: Create a program that allows a user to view and alter a class schedule. To make the class schedule, you'll need to use TWO string vectors: courseCodes and courseNames. Note: Throughout the lab, you can assume the user will enter the correct data type you're expecting. So, if you're asking for an integer, assume they will correctly always enter an integer. Your program should utilize four functions:
main Parameters: none Return value: 0 Purpose: Loop through the user menu letting the user choose options until they'd wish to stop ViewSchedule Parameters: codes and class names (both by reference) Return value: none Purpose: display all the items in the vectors. Keep each course code in line with the corresponding course name addClass Parameters: codes and class names (both by reference) Return value: 0 on successful add, 1 on unsuccessful add Purpose: add a course to the vectors. Course codes should be checked for being exactly four characters long -- if it's not, return 1 and end function. If it is, add to the code vector, query for the course name and add to the name vector. Retum O
removeClass Parameters: codes and class names (both by reference) Return value: 0 on successful remove, 1 on unsuccessful remove Purpose: remove a course from the vectors. Should not display the vectors here. Ask the user which item they'd like to remove ... check to see if the number is valid (0
Exit Exit the menu View Schedule Check to see if the vector contents aren't empty Call view schedule function if they aren't Add Class Call add class function Check to see if 0 or 1 - tell the user whether a successful addition occurred or Remove Class Check to see if the vector contents aren't empty If they aren't Display vector contents Call remove class function Check to see if 0 or 1 - tell the user whether a successful removal occurred or not Incorrect menu option Display an error to the user that the menu option isn't valid Hints: For the course name, you will need to get the entire contents of the line. So, if they entered in Intermediate Programming" or "Introduction to Computer Programming", make sure you get the entire line. The string function "getline" is very useful for this, as the vectors are string type. You'll find, if you try to mix the input types
: cin>> variable getline(cin, variable) That a getine following a "cin >> variable" line will be skipped. There are two solutions to this:
Make all your variables strings (even menu option queries) and make every input a getline statement Put the line "cin.ignore(" before you run your getiline command if you've mixed "cin >> variable statements in your code Example Execution (without BONUS): lcome to the class schedule manager. - Exit Vie Schedule Add Class Remove Class ich es option would you likel 6 That's not a valid u option. Try again. - Exit 1. Vin Schedule Add Class 1. Remont Class ich es option would you like i Fou have to add classes first! .Vie schudile 2. Add chess 1. RemoveClass ich en option would you like? 2 what course code would you like to add 4 characters long) 111 Error in adding course. Try a - Exit 1. Vie Schedule Add Class 1. Reve less ich mens option would you like? hat course code would you like to add 4 characters long) 1294 that is the course rumel Intermediate Programming Fone added! Exit Vie Schedule Add Class 1. Remove Class Lahich was option would you like? 2 hat course code would you like to add (4 characters long) 121 That is the course Introduction to computer Programin use added Exit View Schedule Add Class Rene Class hich muss option would you like 1 : 1984 termediate Programming 1234 Introduction to computer Programming Exit View Schedule Add Class ... Remove Claus hich menu option would you likula Beedbye!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started