- Q1 50 Marks Using The Array Class Defined Below Add Functions That Perform The Following Tasks Allows The User To 1 (41.08 KiB) Viewed 14 times
Q1: (50 MARKS) Using the Array class defined below, add functions that perform the following tasks: • Allows the user to
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Q1: (50 MARKS) Using the Array class defined below, add functions that perform the following tasks: • Allows the user to
Q1: (50 MARKS) Using the Array class defined below, add functions that perform the following tasks: • Allows the user to populate the array. displays all the elements (items) of the list displays an element in a specified position in an array (the argument specifies the position) Create a Student class with three data members; name, SMU student number, and score. Implement any necessary member(s) so that Student can work with the Array template class. Student with a bigger score is considered greater than a Student with a smaller score, vice versa. reverses the order of elements in an array sorts the elements in an array in an ascending order sorts the elements in an array in a descending order Write a main() function that demonstrates that the Array template class works; demonstrate using any built-in type and Student type. The program should prompt the user for the size of the list (i.e. Array), and allow the user to populate the list values. Do not allow the user to enter a negative number as the size of the list, if they enter a negative number, ask for the size again Page 1 of 3 until they enter a non-negative number. If the size is zero, that would mean the user has no values to enter to the list, therefore the program should not display any values of the list, instead display the message "No list created!". Save the file as listStudent.cpp #include <iostream> using namespace std; template class > class Array private: ) public: "data/ int size: 1} # template class T> Array Array(7 d, int si ( Array ( d, int az void showFirat ( data - di size - 31 template class T void Array<T>::showFirst (1 cout<< Firat item on the list is ccdata101<<endl;