CCS0015L (Data Structures and Algorithms) : Practical Exam
CCS0015L (Data Structures and Algorithms) : Practical Exam
CCS0015L
(DATA STRUCTURES AND ALGORITHMS)
PRACTICAL EXAM
1
Student Name / Group Aaron Castro
Name:
Name Role
Members (if Group):
Section:
TC02
Professor:
Julius Claour
Directions: Complete the program below that satisfy the given problem specification and output. Look for
the functions or sections of the function with //TODO. Paste your completed source code in the Code
portion then highlight the statement(s) that you filled in the incomplete program with color yellow.
Problem: You are tasked to complete the program that will implement a StudentSet ADT with the following
functions:
Given Program:
#include <iostream>
#include <string>
using namespace std;
class StudentSet {
private:
string set[MAX_SIZE];
int size;
public:
StudentSet() {
size = 0;
}
void print() {
//TODO
}
};
int main() {
StudentSet s;
string name;
// Add some students to the set
s.add("Akira");
s.add("JL");
s.add("Gelo");
s.add("Mikki");
s.add("Nate");
if (s.contains(name)) {
cout << "Yipee!!! He is in the set." << endl;
} else {
cout << "Oops! He is not in the set." << endl;
return 0;
}
Sample Output:
Code:
#include <iostream>
#include <string>
using namespace std;
class StudentSet
{
private:
string set[MAX_SIZE];
int size;
public:
StudentSet()
{
size = 0;
}
void print()
{
// Print the current set of students
cout << "Current set of students:" << endl;
for (int i = 0; i < size; i++)
{
cout << set[i] << endl;
}
}
};
int main()
{
StudentSet s;
string name;
// Add some students to the set
s.add("Akira");
s.add("JL");
s.add("Gelo");
s.add("Mikki");
s.add("Nate");
if (s.contains(name))
{
cout << "Yipee!!! " << name << " is in the set." << endl;
} else {
cout << "Oops! " << name << " is not in the set." << endl;
}
return 0;
}