Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Download: http://solutionzip.com/downloads/student-cpp/
- Create a class named Student that has three member variables:
- • name – A string for the name of the student.
- • numClasses – An integer for how many courses the student is currently enrolled in.
- • classList – An array of strings for the names of the classes the student is enrolled in.
- Write appropriate constructor(s), mutator (set), and accessor (get) methods for the class
- along with the following:
- • A function that inputs all values from the user, including the list of class names.
- • A function that outputs the name and list of all courses.
- • A function that resets the number of classes to 0 and the classList to an empty array
- (with null strings).
- The main() should test all of these functions. It should perform the following steps in a loop:
- • It should ask the user to input a students data.
- • Display the entered data back (in a well-formatted way).
- • Ask the user if they want to enter the data again (y/n).
- 1• If ’n’, then the program ends, otherwise it should clear the student class object and
- repeat the loop (ask the user to enter new data…).
- Note: The statement ‘cin >> variable;’ leaves a newline character in the buffer. This can be
- a problem if you are mixing ‘cin >> variable;’ and the ‘getline’ function (that reads a line
- of input). Use ‘cin.ignore’ function to discard the newline character after using ‘cin’.
- Filename: student.cpp
- Download: http://solutionzip.com/downloads/student-cpp/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement