Question

Write the following program in C++. Review structures, pointers and dynamic memory allocation from CSIT 839....

Write the following program in C++.

Review structures, pointers and dynamic memory allocation from CSIT 839. Also, review pointers and dynamic memory allocation posted here under Pages. For sorting, you can refer to the textbook for Co Sci 839 or google "C++ sort functions". I've also included under files, a sample C++ source file named sort_binsearch.cpp which gives an example of both sorting and binary search. The Bubble sort is the simplest. For binary search too, you can refer to Co Sci 839 or google: "binary search function in C++".

You can separate the main function from the definitions of the functions by adding a second C++ file to your project (Project/Add New Item: C++ File), and write the function definitions there. Likewise, you can separate the class definition by adding a header file to the project (Project/Add New Item: Header File), and write the class definition there. Thus, you should have two cpp files: courses_main.pp and courses_functions.cpp and courses.h.

Define a class called Course which contains a c-string for its title (e.g.: CSIT 839), an integer for its number of units and a character for the letter grade received. Member functions must be added as needed: constructor to initialize a Course object, to edit the information of an existing object, to display Course information, the function for calculating the GPA and a destructor to free dynamically allocated memory for each object. The destructor ensures that each and every object created will be freed. This will make it unnecessary for Quit to call a delete() function to delete all objects and free their allocated memory .

In main, declare an array of 10 Course pointers, initialized to NULL and continuously present the following menu to the user asking him or her to choose one:

  1. Add new course
  2. Edit an existing course
  3. Display a course
  4. List all courses
  5. Display GPA
  6. Delete all courses
  7. Quit

If Add new course is selected, pass the array of pointers to an add() function, which dynamically allocates memory for a new Course, reads the course information (title, units and grade) from the user, saves its pointer in the array of pointers and displays the menu again.

If Edit is selected, the program passes the array of pointers and size to edit() function that displays all courses with a number next to them and asks which course to edit, like so:

Select the course to edit:

  1. Math 102
    2. CSIT 839
    3. English 112

Enter your selection: 2

It then reads new course information from the user and writes to the selected course using its pointer, as follows:

Enter course name: CSIT 802

Enter number of units: 5

Enter grade: B

If Display a course is selected, the program must pass the array of pointers and size to a sort() function to sort the pointers, ask the user to enter a course, pass the course name and array of pointers to a bin_search() function which will do a binary search on the course names using the pointers and either find and display the course information, or that “Course was not found”. For example, if CSIT 839 is to be searched, when found, it will display: CSIT 839, 3 units, grade: A.

If List all courses is selected, the program must again pass the array of pointers and size to the sort() function to sort the pointers based on their title and then pass the array of pointers and size to a display() function to display all courses.

If Display GPA is selected, the program must calculate and display the GPA as follows:

GPA = (sum of the products of units x points for all courses) / total number of units for all courses, where points are 4 for A, 3 for B, 2 for C, 1 for D and 0 for F. For example, if only 3 courses are taken worth 3, 5 and 4 units with the letter grade of C, A and B, respectively, the GPA is given by (3 units x 2 points + 5 units x 4 points + 4 units x 3 points) / (3 + 5 + 4) = 3.17.

If Delete all courses is selected, the program must pass the array of pointers and size to a delete_course() function that will delete all structures created dynamically and set their pointers to NULL.

Selecting Quit must pass all pointers and size to the delete() function that will delete all structures created dynamically, set the pointers to NULL and quit the program. Not explicitly deleting the objects created dynamically will cause memory leak.

The following is a sample run of the program:

Select one of the following actions:

  1. Add new course
  2. Edit an existing course
  3. Display a course
  4. List all courses
  5. Display GPA
  6. Delete all courses
  7. Quit

Enter selection number: 1

Enter course name: Math 102

Enter number of units: 3

Enter grade received: C

Select one of the following actions:

  1. Add new course
  2. Edit an existing course
  3. Display a course
  4. List all courses
  5. Display GPA
  6. Delete all courses
  7. Quit

Enter selection number: 2

Editing: Math 102, 3 units, grade: B

Enter course name: Math 102

Enter units: 4

Enter grade: B

Course modified.

Select one of the following actions:

  1. Add new course
  2. Edit an existing course
  3. Display a course
  4. List all courses
  5. Display GPA
  6. Delete all courses
  7. Quit

Enter selection number: 3

Math 102, 3 units, grade: B

Select one of the following actions:

  1. Add new course
  2. Edit an existing course
  3. Display a course
  4. List all courses
  5. Display GPA
  6. Delete all courses
  7. Quit

Enter selection number: 1

Enter course name: CSIT 839

Enter number of units: 3

Enter grade: A

Select one of the following actions:

  1. Add new course
  2. Edit an existing course
  3. Display a course
  4. List all courses
  5. Display GPA
  6. Delete all courses
  7. Quit

Enter selection number: 4

CSIT 839, 3 units, grade: A

Math 102, 3 units, grade: B

Select one of the following actions:

  1. Add new course
  2. Edit an existing course
  3. Display a course
  4. List all courses
  5. Display GPA
  6. Delete all courses
  7. Quit

Enter selection number: 5

GPA = 3.50

Select one of the following actions:

  1. Add new course
  2. Edit an existing course
  3. Display a course
  4. List all courses
  5. Display GPA
  6. Delete all courses
  7. Quit

Enter selection number: 6

All courses deleted!

Select one of the following actions:

  1. Add new course
  2. Edit an existing course
  3. Display a course
  4. List all courses
  5. Display GPA
  6. Delete all courses
  7. Quit

Enter selection number: 7

Press any key to continue.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

CODE:

//Courses.h

#ifndef COURSES_H
#define COURSES_H

class Courses
{
private:
struct CourseList
{
char courseNum[10];
char courseName[25];
char courseSch[20];
CourseList *next;
};
CourseList *head;

void displayArrayChar(char [], int);

public:
Courses(void)
{head=NULL;}
~Courses(void);
void appendCourse(char [],char [], char []);
void appendCourse(CourseList *);
void deleteCourse(char []);
bool searchforCourse(char []);
void displayAllCourses(void);
void editCourses(char [], char [], int );
void emptyCourses(void); //function called when a student is deleted
CourseList* getHead(void){return head;}
//friend void StudentInfo::insertStudent(char [], char [], int [], CourseList *);
};

#endif
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//studentinfo.h

#ifndef STUDENTINFO_H
#define STUDENTINFO_H

#include <iostream>
#include "Courses.h"
using namespace std;


class StudentInfo
{
private:
struct StudentList
{
char firstName[12];
char lastName[12];
int ssn[9];
Courses studentCourses;
struct StudentList *next;
};

StudentList *ssnhead;

int tempStoreSSN[9];
void displayArrayChar(char [], int);
void displayArrayInt(int []);
bool testIntArray(int [], int []);


public:
StudentInfo(void)
{ssnhead=NULL;}
~StudentInfo(void);
void insertStudent(char [], char [], int [], Courses &);
void insertStudent(char fn[], char ln[], int s[]);
void deleteStudent(int []);
bool searchBylast(char []);
bool searchByssn(int []);
void displayAllStudents(void);

void editStudentInfo(int []);
void editStudentInfo(char [],int);
int getTempssn(int);
void storessnTemp(char [], int);
};
#endif
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//courses.cpp

#include <iostream>
#include <ctype.h>
#include <string.h>
#include "courses.h"
#include "studentinfo.h"
using namespace std;

Courses::~Courses(void)
{
CourseList *nodePtr, *nextNode;
nodePtr=head;

while (nodePtr !=NULL)
{
nextNode=nodePtr->next;
delete nodePtr;
nodePtr=nextNode;
}
head=NULL;
}

void Courses::appendCourse(CourseList *tempHead) //should only pass the head pointer of the node
{
CourseList *nodePtr, *nodeTempPtr, *newNode;
nodePtr=head;
nodeTempPtr=nodePtr;

while(nodeTempPtr->next !=NULL)
{nodePtr=nodePtr->next;
}

nodeTempPtr = tempHead;

while(nodeTempPtr->next !=NULL)
{
newNode=new CourseList;
strcpy(newNode->courseNum, nodeTempPtr->courseNum);
strcpy(newNode->courseName, nodeTempPtr->courseName);
strcpy(newNode->courseSch, nodeTempPtr->courseSch);
newNode->next=NULL;

nodePtr->next=newNode;
nodePtr=nodePtr->next;
nodeTempPtr=nodeTempPtr->next;
}

}

void Courses::appendCourse(char cNum[], char cName[], char cSch[])
{
CourseList *newNode, *nodePtr;
newNode=new CourseList;

strcpy(newNode->courseNum, cNum);
strcpy(newNode->courseName, cName);
strcpy(newNode->courseSch, cSch);
newNode->next=NULL;

if(!head)
head=newNode;
else
{
nodePtr=head;

while(nodePtr->next)
{
nodePtr=nodePtr->next;
}
nodePtr->next=newNode;
}
}

void Courses::emptyCourses(void)
{
CourseList *nodePtr, *nextNode;
nodePtr=head;

while (nodePtr !=NULL)
{
nextNode=nodePtr->next;
delete nodePtr;
nodePtr=nextNode;
}
head=NULL;
}

void Courses::displayAllCourses(void)
{
CourseList *nodePtr;
nodePtr=head;

if(!head)
cout<< "\nThis Student isn't registered for any classes\n";

while(nodePtr)
{
displayArrayChar(nodePtr->courseNum, 10);
cout<< " ";
displayArrayChar(nodePtr->courseName, strlen(nodePtr->courseName));
cout<< " ";
displayArrayChar(nodePtr->courseSch, strlen(nodePtr->courseSch));
cout<<"\n";
nodePtr=nodePtr->next;
}

}

void Courses::displayArrayChar(char array[], int elms)
{
for(int counter=0; counter < elms; counter++)
{
cout<< array[counter];
}
}

void Courses::deleteCourse(char array[])
{
CourseList *nodePtr, *previousNode;

head->courseNum[10]=NULL; //THE FUNCTION WON'T WORK W/O THIS

if(!head)
return;

if(strcmp(head->courseNum, array) == 0)
{
nodePtr=head->next;
delete head;
head=nodePtr;
}

else
{
nodePtr=head;

while(nodePtr->next !=NULL && strcmp(array, nodePtr->courseNum) !=0)
{
previousNode=nodePtr;
nodePtr=nodePtr->next;
}
previousNode->next=nodePtr->next;
delete nodePtr;
}

}

bool Courses::searchforCourse(char array[])
{
CourseList *nodePtr;

if(!head)
return false;

if(strcmp(head->courseNum, array) == 0)
return true;

else
{
nodePtr=head;

while(nodePtr !=NULL && strcmp(nodePtr->courseNum, array) !=0)
{
if(strcmp(nodePtr->courseNum, array) ==0)
return true;
nodePtr=nodePtr->next;
}
return false;
}
}

void Courses::editCourses(char course[], char change[], int choice)
{
CourseList *nodePtr;

nodePtr=head;
head->courseNum[1]=NULL; //THE FUNCTION WON'T WORK WITHOUT THIS
if(strcmp(head->courseNum, course) == 0);

else
{
while(nodePtr->next !=NULL && strcmp(course, nodePtr->courseNum) !=0)
{
nodePtr=nodePtr->next;
}
}

switch(choice)
{
case 1://Changes the Course Number
strcpy(nodePtr->courseNum, change);
break;
case 2://Changes the Course Name
strcpy(nodePtr->courseName, change);
break;
case 3://Changes the Course Schedule
strcpy(nodePtr->courseSch, change);
break;
}
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//Studentinfo.cpp

#include <iostream>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include "studentinfo.h"
#include "courses.h"
using namespace std;

StudentInfo::~StudentInfo(void)
{
StudentList *nodePtr, *nextNode;
nodePtr=ssnhead;
while(nodePtr !=NULL)
{
nextNode=nodePtr->next;
ssnhead->next->studentCourses.emptyCourses();
delete nodePtr;
nodePtr=nextNode;
}
ssnhead->next=NULL;
}

void StudentInfo::insertStudent(char fn[], char ln[], int s[], Courses &stdcourses)
{
StudentList *newNode, *nodePtr, *previousNode;
newNode=new StudentList;

strcpy(newNode->firstName, fn);
strcpy(newNode->lastName, ln);
for(int count=0; count<9; count++)
newNode->ssn[count]=s[count];

newNode->studentCourses.appendCourse(stdcourses.getHead());
newNode->next=NULL;
if(ssnhead==NULL) //There should be no information stored in the head
{
ssnhead=newNode;
}
else
{
nodePtr= ssnhead;
while(nodePtr !=NULL)
{
previousNode=nodePtr;
nodePtr=nodePtr->next;
}
if(previousNode==NULL)
{
ssnhead->next=newNode; //There should be no information stored in the head
newNode->next=nodePtr;
}
else
{
previousNode->next=newNode;
newNode->next=nodePtr;
}
}
}

void StudentInfo::insertStudent(char fn[], char ln[], int s[])
{
StudentList *newNode, *nodePtr, *previousNode;
newNode=new StudentList;

strcpy(newNode->firstName, fn);
strcpy(newNode->lastName, ln);
for(int count=0; count<9; count++)
newNode->ssn[count]=s[count];

if(ssnhead==NULL)
{
ssnhead->next=newNode;
newNode->next=NULL;
}
else
{
nodePtr=ssnhead;

while(nodePtr !=NULL)
{
previousNode=nodePtr;
nodePtr=nodePtr->next;
}
if(previousNode==NULL)
{
ssnhead=newNode;
newNode->next=nodePtr;
}
else
{
previousNode->next=newNode;
newNode->next=nodePtr;
}
}
}

void StudentInfo::deleteStudent(int s[])
{
StudentList *nodePtr, *previousNode;

if(s[0] ==-1)
{
for(int c=0; c<10; c++)
s[c]=tempStoreSSN[c];
tempStoreSSN[0]=NULL;
}

if(!ssnhead->next)
return;
if(testIntArray(ssnhead->next->ssn, s) == true)
{
nodePtr = ssnhead->next->next;
ssnhead->next->studentCourses.emptyCourses();
delete ssnhead->next;
ssnhead->next=nodePtr;
}
else
{
nodePtr=ssnhead->next;

while(nodePtr !=NULL && testIntArray(ssnhead->next->ssn, s) != true)
{
previousNode=nodePtr;
nodePtr=nodePtr->next;
}
previousNode->next=nodePtr->next;
ssnhead->next->studentCourses.emptyCourses();
delete nodePtr;
}
}

void StudentInfo::displayArrayChar(char array[], int elms)
{
for(int counter=0; counter< elms; counter++)
{
cout<< array[counter];
}
}

void StudentInfo::displayArrayInt(int array[])
{
for(int counter = 0; counter<9; counter++)
{
cout<< array[counter];
}
}

void StudentInfo::displayAllStudents()
{
StudentList *nodePtr;
nodePtr = ssnhead;

if(ssnhead==NULL)
{
cout<< "\nThere aren't any students in the database.\n";
return;
}


while(nodePtr)
{
cout << " made it in" << endl;
cout<< "\n";
displayArrayChar(nodePtr->firstName, strlen(nodePtr->firstName));
cout<< " ";
displayArrayChar(nodePtr->lastName, strlen(nodePtr->lastName));
cout<< " ";
displayArrayInt(nodePtr->ssn);
cout<< "\n";
nodePtr->studentCourses.displayAllCourses();
cout<< endl;

}
}

bool StudentInfo::searchBylast(char name[])
{
StudentList *nodePtr;
nodePtr=ssnhead->next;
int temp=0;

if(nodePtr==NULL)
return false;

while(nodePtr !=NULL)
{
if(strcmp(name, nodePtr->lastName) == 0)
{
cout<< endl<< (temp + 1)<< "-";
displayArrayChar(nodePtr->lastName, strlen(nodePtr->lastName)); cout<< ", ";
displayArrayChar(nodePtr->firstName, strlen(nodePtr->firstName)); cout<< endl;
temp++;
}
if(nodePtr==NULL && temp !=0)
{
return true;
}
nodePtr=nodePtr->next;
}
return false;
}

bool StudentInfo::searchByssn(int social[])
{
StudentList *nodePtr;
nodePtr=ssnhead->next;

if(nodePtr==NULL)
return false;

while(nodePtr !=NULL)
{
if(testIntArray(social, nodePtr->ssn) == true)
{
cout<< "\n";
displayArrayChar(nodePtr->lastName, strlen(nodePtr->lastName)); cout << ", ";
displayArrayChar(nodePtr->firstName, strlen(nodePtr->firstName)); cout<< endl;
return true;
}
nodePtr=nodePtr->next;
}
return false;
}

void StudentInfo::storessnTemp(char name[], int count)
{
StudentList *nodePtr;
nodePtr=ssnhead->next;
int counter=1;

while(nodePtr !=NULL)
{
if(strcmp(name, nodePtr->lastName) == 0)
{
if(counter == count)
{
for(int c=0; c<9; c++)
tempStoreSSN[c] = nodePtr->ssn[c];
}
else
counter++;
}
nodePtr= nodePtr->next;
}
}

int StudentInfo::getTempssn(int e)
{
return tempStoreSSN[e];
}

void StudentInfo::editStudentInfo(char futurechange[], int choice)
{
StudentList *nodePtr;

nodePtr=ssnhead->next;
while(nodePtr !=NULL && testIntArray(tempStoreSSN, nodePtr->ssn) == true)
{
nodePtr=nodePtr->next;
}

switch(choice)
{
case 1://Changes first name
strcpy(nodePtr->firstName, futurechange);
break;
case 2://Changes last name
strcpy(nodePtr->lastName, futurechange);
break;
}
}

void StudentInfo::editStudentInfo(int futurechange[])
{
StudentList *nodePtr;

nodePtr=ssnhead->next;

while(testIntArray(tempStoreSSN, nodePtr->ssn) ==true && nodePtr !=NULL)
{
nodePtr=nodePtr->next;
}

for(int count = 0; count<9; count++)
nodePtr->ssn[count]=futurechange[count];
}
bool StudentInfo::testIntArray(int a[], int b[])
{
for(int count=0; count<9; count++)
{
if(a[count] != b[count])
return false;
}
return true;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//mainprogram.cpp

#include <iostream>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include "studentinfo.h"
#include "courses.h"

#define ERROR "\nYou\'ve Entered An Invalid Character!\n"

void displayname(void);
void getStudentInfo(StudentInfo &);
bool changeCase(char [], int);
void getCourseInfo(Courses &);
bool yesorno(void);
int mainMenu(void);
void directions(void);

void search(StudentInfo &);
void insertStudent(StudentInfo &);
void addStudent(StudentInfo &);
void deleteStudent(StudentInfo &);
void editStudent(StudentInfo &);


void main (void)
{
StudentInfo spartans;

int choice;
displayname();
do
{
choice = mainMenu();
switch(choice)
{
case 0: spartans.displayAllStudents();
break;
case 1: insertStudent(spartans);
break;
case 2: //Edit
break;
case 3: search(spartans);
break;
case 4: deleteStudent(spartans);
break;
case 5: cout << "\n\nGOODBYE!!\n\n";
break;
}
}
while(choice != 5);

}


void getCourseInfo(Courses &l)
{
char cname[10];
char cd[25];
char sc[20];
bool execution = true;

cout << "\nEnter The Course Number & Session Number: ";
cin.getline(cname, 11);
execution = changeCase(cname, 3);
if(execution == false)
{
cout << "\nThe Course Has Not Been Entered Into The System ";
cout << "Because Of Input Problems.\n"; directions();
return;
}

cout << "Enter The Course Description: ";
cin.getline(cd, 25);
execution = changeCase(cd,4);
if(execution == false)
{
cout << "\nThe Course Has Not Been Entered Into The System ";
cout << "Because Of Input Problems.\n"; directions();
return;
}

cout << "Enter the Course Schedule: ";
cin.getline(sc, 20);
execution = changeCase(sc, 5);
if(execution == false)
{
cout << "\nThe Course has Not Been Entered Into The System ";
cout << "Because Of Input Problems.\n"; directions();
return;
}

if(execution == true)
l.appendCourse(cname,cd,sc);

}

bool changeCase(char array[], int choice)
{
int elm = strlen(array);
int count = 0;
switch(choice)
{
case 1:
for(count = 0; count < elm; count++)
{
if(count== 0 && isalpha(array[count]))
{
array[count] = toupper(array[count]);
}
else if(isalpha(array[count]))
{
array[count] = tolower(array[count]);
}
else
{
cout << ERROR; return false;

}
}
break;

case 2:
for(count = 0; count < 10; count++)
{
if(isdigit(array[count]));
else
{
cout << ERROR; return false;
}
}
break;

case 3:
for( count = 0; count < elm; count++)
{
if(count <=2)
{
if(isalpha(array[count]))
{
array[count] = toupper(array[count]);
}
else
{
cout << ERROR; return false;
}
}
else if(count == 3)
{
if(isspace(array[count]));

else
{
cout << ERROR; return false;
}
}
else if(count >4 && count <=6)
{
if(isdigit(array[count]));

else
{
cout << ERROR; return false;
}
}
else if(count == 7)
{
if(array[count] == '-');

else
{
cout << ERROR; return false;
}
}
else
{
if(isdigit(array[count]));

else
{
cout << ERROR; return false;
}
}
}
break;

case 4:
for(count = 0; count < elm; count++)
{
if(isalpha(array[count]))
{
if(count == 0)
{
array[count] = toupper(array[count]);
}
else
{
array[count] = tolower(array[count]);
}
}
else if(isspace(array[count]))
{
if(isalpha(array[count+1]))
{
array[count] = toupper(array[count]);
count++;
}
else
{
cout << ERROR; return false;
}
}
else
{
cout << ERROR; return false;
}
}
break;

case 5:
for(int count = 0; count < elm; count++)
{
if(isalpha(array[count]))
{
array[count] = toupper(array[count]);
}
}
break;
}
return true;
}


void directions(void)
{
cout << "\n\nWhen entering data follow the instructions below.\n";
cout << "\t*Enter all names beginning with a capital letter. Ex: Tommy White\n";
cout << "\t*All social security numbers must not have blank spaces or dashes. Ex: 277892345\n";
cout << "\t*Enter \'y\' or \'n\' for all yes or no questions.\n";
cout << "\t*Below is an example of how to input all course information.\n";
cout << "\t\t-Course Number & Session Number: CSC 351-01\n";
cout << "\t\t-Course Description: Linear Algebra\n";
cout << "\t\t-Course Schedule: MWF 0900AM 1000AM\n";
}

bool yesorno(void)
{
char ans;
do
{
cout << "\nEnter Yes or No(Y or N) For The Above Question: ";
cin >> ans;

cin.ignore();

if(tolower(ans) != 'y' && tolower(ans) != 'n')
{
cout << ERROR;
directions();
cout << "\n\nPlease Try Again!!";
}
}
while(tolower(ans) != 'y' && tolower(ans) != 'n');

if(tolower(ans) == 'y')
return true;
else
mainMenu();
return false;

}

int mainMenu(void)
{
int ans;

do
{
cout << "\nMain Menu\n----------\n";
cout << "\t0-Display All Students In The Database\n";
cout << "\t1-Add a Student\n";
cout << "\t-Add a Non-Existing Student\n";
cout << "\t-Register a Non-Existing Student\n";
cout << "\t-Edit a Student\'s Information\n";
cout << "\t-2-Edit a Student\'s Information\n";
cout << "\t\t-Edit a \'Student\'s Courses\n";
cout << "\t\t-Edit a \'Student\'s Personal Information\n";
cout << "\t\t-Register An Existing Student\n";
cout << "\t3-Search For A Student\n";
cout << "\t4-Delete a Student\n";
cout << "\t\t-Delete a Student from The Database\n";
cout << "\t5-Quit\n";
cout << "\nEnter the corresponding number next to the option of your choice: ";
cin >> ans;
cin.ignore();

if(ans != 0 && ans != 1 && ans != 2 && ans != 3 && ans != 4 && ans != 5)
{
cout << ERROR; cout << "\nPlease Try Again!!\n";
}
}
while(ans != 0 && ans != 1 && ans != 2 && ans != 3 && ans != 4 && ans != 5);

return ans;
}

void getStudentInfo(StudentInfo &l)
{
char fname[12];
char lname[12];
//char tempsocial[9];
int social[9];
bool execution = true;

cout << "\nEnter The Student\'s First name: ";
cin.getline(fname, 13);

execution = changeCase(fname, 1);
if(execution == false)
{
cout << "\nThe Student\'s Name Has Not Been Entered Into The System ";
cout << "Because Of Input Problems.\n"; directions();
return;
}

cout << "Enter The Student\'s Last Name: ";
cin.getline(lname, 13);

execution = changeCase(lname,1);
if(execution == false)
{
cout << "\nThe Student\'s Name Has Not Been Entered Into The System ";
cout << "Because Of Input Problems.\n"; directions();
return;
}

cout << "Enter the Student\'s Social Security Number: ";
cin >> social[9];


if(execution == false)
{
cout << "\nThe Student\'s Social Security Number Has Not Been Entered Into The System ";
cout << "Because Of Input Problems.\n"; directions();
return;
}

bool ans;
Courses temp;

cout << "\nWould You Like To Register This Student For A Course? ";
ans = yesorno();
if(ans == true)
{
while(ans == true)
{
getCourseInfo(temp);
cout << "\nWould You Like To Register This Student For Another course? ";
ans = yesorno();
}
l.insertStudent(lname, fname, social);
}
else
{
l.insertStudent(lname, fname, social);

}
}


void addStudent(StudentInfo &n)
{
bool ans;

do
{
getStudentInfo(n);
cout << "\nWould You Like to Add Another Student? ";
ans = yesorno();
}
while (ans == true);
}

void search(StudentInfo &l)
{
bool a, searcher;
int choice, count;

do
{
do
{
cout << "\nEnter 1 to search by last name, or 2 to search ";
cout << "by social security number. " << "\nEnter Here: ";
cin >> choice;

switch(choice)
{
case 1:
char lname[12];
cout << "\nEnter The Student\'s Last Name: ";
cin.getline(lname, 13);
searcher = changeCase(lname, 1);
if(searcher == true)
{
searcher = l.searchBylast(lname);
if(searcher == false)
{
cout << "\nThere is no student by that last name";
cout << " in the database.\n";
}
a = false;
}
else
{
cout << ERROR << "Please Try Again!!\n";
a = true;
}
break;

case 2:
int social[9];
for(count = 0; count < 10; count++)
{
cin >> social[count];
}
searcher = l.searchByssn(social);
if(searcher == false)
{
cout << "\nThere is no student that has that social ";
cout << "security number in the database.\n";
}
a = false;
break;

default:
cout << ERROR; a = true;
}
}
while(a = true);
cout << "\nWould You Like To Try Another Search? ";
a = yesorno();
}
while(a == true);
}

void deleteStudent(StudentInfo &sa)
{
int s[9];
bool a;

cout << "\nEnter the student\'s social security number: ";
&nbs//Courses.h

#ifndef COURSES_H
#define COURSES_H

class Courses
{
private:
struct CourseList
{
char courseNum[10];
char courseName[25];
char courseSch[20];
CourseList *next;
};
CourseList *head;

void displayArrayChar(char [], int);

public:
Courses(void)
{head=NULL;}
~Courses(void);
void appendCourse(char [],char [], char []);
void appendCourse(CourseList *);
void deleteCourse(char []);
bool searchforCourse(char []);
void displayAllCourses(void);
void editCourses(char [], char [], int );
void emptyCourses(void); //function called when a student is deleted
CourseList* getHead(void){return head;}
//friend void StudentInfo::insertStudent(char [], char [], int [], CourseList *);
};

#endif
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//studentinfo.h

#ifndef STUDENTINFO_H
#define STUDENTINFO_H

#include <iostream>
#include "Courses.h"
using namespace std;


class StudentInfo
{
private:
struct StudentList
{
char firstName[12];
char lastName[12];
int ssn[9];
Courses studentCourses;
struct StudentList *next;
};

StudentList *ssnhead;

int tempStoreSSN[9];
void displayArrayChar(char [], int);
void displayArrayInt(int []);
bool testIntArray(int [], int []);


public:
StudentInfo(void)
{ssnhead=NULL;}
~StudentInfo(void);
void insertStudent(char [], char [], int [], Courses &);
void insertStudent(char fn[], char ln[], int s[]);
void deleteStudent(int []);
bool searchBylast(char []);
bool searchByssn(int []);
void displayAllStudents(void);

void editStudentInfo(int []);
void editStudentInfo(char [],int);
int getTempssn(int);
void storessnTemp(char [], int);
};
#endif
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//courses.cpp

#include <iostream>
#include <ctype.h>
#include <string.h>
#include "courses.h"
#include "studentinfo.h"
using namespace std;

Courses::~Courses(void)
{
CourseList *nodePtr, *nextNode;
nodePtr=head;

while (nodePtr !=NULL)
{
nextNode=nodePtr->next;
delete nodePtr;
nodePtr=nextNode;
}
head=NULL;
}

void Courses::appendCourse(CourseList *tempHead) //should only pass the head pointer of the node
{
CourseList *nodePtr, *nodeTempPtr, *newNode;
nodePtr=head;
nodeTempPtr=nodePtr;

while(nodeTempPtr->next !=NULL)
{nodePtr=nodePtr->next;
}

nodeTempPtr = tempHead;

while(nodeTempPtr->next !=NULL)
{
newNode=new CourseList;
strcpy(newNode->courseNum, nodeTempPtr->courseNum);
strcpy(newNode->courseName, nodeTempPtr->courseName);
strcpy(newNode->courseSch, nodeTempPtr->courseSch);
newNode->next=NULL;

nodePtr->next=newNode;
nodePtr=nodePtr->next;
nodeTempPtr=nodeTempPtr->next;
}

}

void Courses::appendCourse(char cNum[], char cName[], char cSch[])
{
CourseList *newNode, *nodePtr;
newNode=new CourseList;

strcpy(newNode->courseNum, cNum);
strcpy(newNode->courseName, cName);
strcpy(newNode->courseSch, cSch);
newNode->next=NULL;

if(!head)
head=newNode;
else
{
nodePtr=head;

while(nodePtr->next)
{
nodePtr=nodePtr->next;
}
nodePtr->next=newNode;
}
}

void Courses::emptyCourses(void)
{
CourseList *nodePtr, *nextNode;
nodePtr=head;

while (nodePtr !=NULL)
{
nextNode=nodePtr->next;
delete nodePtr;
nodePtr=nextNode;
}
head=NULL;
}

void Courses::displayAllCourses(void)
{
CourseList *nodePtr;
nodePtr=head;

if(!head)
cout<< "\nThis Student isn't registered for any classes\n";

while(nodePtr)
{
displayArrayChar(nodePtr->courseNum, 10);
cout<< " ";
displayArrayChar(nodePtr->courseName, strlen(nodePtr->courseName));
cout<< " ";
displayArrayChar(nodePtr->courseSch, strlen(nodePtr->courseSch));
cout<<"\n";
nodePtr=nodePtr->next;
}

}

void Courses::displayArrayChar(char array[], int elms)
{
for(int counter=0; counter < elms; counter++)
{
cout<< array[counter];
}
}

void Courses::deleteCourse(char array[])
{
CourseList *nodePtr, *previousNode;

head->courseNum[10]=NULL; //THE FUNCTION WON'T WORK W/O THIS

if(!head)
return;

if(strcmp(head->courseNum, array) == 0)
{
nodePtr=head->next;
delete head;
head=nodePtr;
}

else
{
nodePtr=head;

while(nodePtr->next !=NULL && strcmp(array, nodePtr->courseNum) !=0)
{
previousNode=nodePtr;
nodePtr=nodePtr->next;
}
previousNode->next=nodePtr->next;
delete nodePtr;
}

}

bool Courses::searchforCourse(char array[])
{
CourseList *nodePtr;

if(!head)
return false;

if(strcmp(head->courseNum, array) == 0)
return true;

else
{
nodePtr=head;

while(nodePtr !=NULL && strcmp(nodePtr->courseNum, array) !=0)
{
if(strcmp(nodePtr->courseNum, array) ==0)
return true;
nodePtr=nodePtr->next;
}
return false;
}
}

void Courses::editCourses(char course[], char change[], int choice)
{
CourseList *nodePtr;

nodePtr=head;
head->courseNum[1]=NULL; //THE FUNCTION WON'T WORK WITHOUT THIS
if(strcmp(head->courseNum, course) == 0);

else
{
while(nodePtr->next !=NULL && strcmp(course, nodePtr->courseNum) !=0)
{
nodePtr=nodePtr->next;
}
}

switch(choice)
{
case 1://Changes the Course Number
strcpy(nodePtr->courseNum, change);
break;
case 2://Changes the Course Name
strcpy(nodePtr->courseName, change);
break;
case 3://Changes the Course Schedule
strcpy(nodePtr->courseSch, change);
break;
}
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//Studentinfo.cpp

#include <iostream>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include "studentinfo.h"
#include "courses.h"
using namespace std;

StudentInfo::~StudentInfo(void)
{
StudentList *nodePtr, *nextNode;
nodePtr=ssnhead;
while(nodePtr !=NULL)
{
nextNode=nodePtr->next;
ssnhead->next->studentCourses.emptyCourses();
delete nodePtr;
nodePtr=nextNode;
}
ssnhead->next=NULL;
}

void StudentInfo::insertStudent(char fn[], char ln[], int s[], Courses &stdcourses)
{
StudentList *newNode, *nodePtr, *previousNode;
newNode=new StudentList;

strcpy(newNode->firstName, fn);
strcpy(newNode->lastName, ln);
for(int count=0; count<9; count++)
newNode->ssn[count]=s[count];

newNode->studentCourses.appendCourse(stdcourses.getHead());
newNode->next=NULL;
if(ssnhead==NULL) //There should be no information stored in the head
{
ssnhead=newNode;
}
else
{
nodePtr= ssnhead;
while(nodePtr !=NULL)
{
previousNode=nodePtr;
nodePtr=nodePtr->next;
}
if(previousNode==NULL)
{
ssnhead->next=newNode; //There should be no information stored in the head
newNode->next=nodePtr;
}
else
{
previousNode->next=newNode;
newNode->next=nodePtr;
}
}
}

void StudentInfo::insertStudent(char fn[], char ln[], int s[])
{
StudentList *newNode, *nodePtr, *previousNode;
newNode=new StudentList;

strcpy(newNode->firstName, fn);
strcpy(newNode->lastName, ln);
for(int count=0; count<9; count++)
newNode->ssn[count]=s[count];

if(ssnhead==NULL)
{
ssnhead->next=newNode;
newNode->next=NULL;
}
else
{
nodePtr=ssnhead;

while(nodePtr !=NULL)
{
previousNode=nodePtr;
nodePtr=nodePtr->next;
}
if(previousNode==NULL)
{
ssnhead=newNode;
newNode->next=nodePtr;
}
else
{
previousNode->next=newNode;
newNode->next=nodePtr;
}
}
}

void StudentInfo::deleteStudent(int s[])
{
StudentList *nodePtr, *previousNode;

if(s[0] ==-1)
{
for(int c=0; c<10; c++)
s[c]=tempStoreSSN[c];
tempStoreSSN[0]=NULL;
}

if(!ssnhead->next)
return;
if(testIntArray(ssnhead->next->ssn, s) == true)
{
nodePtr = ssnhead->next->next;
ssnhead->next->studentCourses.emptyCourses();
delete ssnhead->next;
ssnhead->next=nodePtr;
}
else
{
nodePtr=ssnhead->next;

while(nodePtr !=NULL && testIntArray(ssnhead->next->ssn, s) != true)
{
previousNode=nodePtr;
nodePtr=nodePtr->next;
}
previousNode->next=nodePtr->next;
ssnhead->next->studentCourses.emptyCourses();
delete nodePtr;
}
}

void StudentInfo::displayArrayChar(char array[], int elms)
{
for(int counter=0; counter< elms; counter++)
{
cout<< array[counter];
}
}

void StudentInfo::displayArrayInt(int array[])
{
for(int counter = 0; counter<9; counter++)
{
cout<< array[counter];
}
}

void StudentInfo::displayAllStudents()
{
StudentList *nodePtr;
nodePtr = ssnhead;

if(ssnhead==NULL)
{
cout<< "\nThere aren't any students in the database.\n";
return;
}


while(nodePtr)
{
cout << " made it in" << endl;
cout<< "\n";
displayArrayChar(nodePtr->firstName, strlen(nodePtr->firstName));
cout<< " ";
displayArrayChar(nodePtr->lastName, strlen(nodePtr->lastName));
cout<< " ";
displayArrayInt(nodePtr->ssn);
cout<< "\n";
nodePtr->studentCourses.displayAllCourses();
cout<< endl;

}
}

bool StudentInfo::searchBylast(char name[])
{
StudentList *nodePtr;
nodePtr=ssnhead->next;
int temp=0;

if(nodePtr==NULL)
return false;

while(nodePtr !=NULL)
{
if(strcmp(name, nodePtr->lastName) == 0)
{
cout<< endl<< (temp + 1)<< "-";
displayArrayChar(nodePtr->lastName, strlen(nodePtr->lastName)); cout<< ", ";
displayArrayChar(nodePtr->firstName, strlen(nodePtr->firstName)); cout<< endl;
temp++;
}
if(nodePtr==NULL && temp !=0)
{
return true;
}
nodePtr=nodePtr->next;
}
return false;
}

bool StudentInfo::searchByssn(int social[])
{
StudentList *nodePtr;
nodePtr=ssnhead->next;

if(nodePtr==NULL)
return false;

while(nodePtr !=NULL)
{
if(testIntArray(social, nodePtr->ssn) == true)
{
cout<< "\n";
displayArrayChar(nodePtr->lastName, strlen(nodePtr->lastName)); cout << ", ";
displayArrayChar(nodePtr->firstName, strlen(nodePtr->firstName)); cout<< endl;
return true;
}
nodePtr=nodePtr->next;
}
return false;
}

void StudentInfo::storessnTemp(char name[], int count)
{
StudentList *nodePtr;
nodePtr=ssnhead->next;
int counter=1;

while(nodePtr !=NULL)
{
if(strcmp(name, nodePtr->lastName) == 0)
{
if(counter == count)
{
for(int c=0; c<9; c++)
tempStoreSSN[c] = nodePtr->ssn[c];
}
else
counter++;
}
nodePtr= nodePtr->next;
}
}

int StudentInfo::getTempssn(int e)
{
return tempStoreSSN[e];
}

void StudentInfo::editStudentInfo(char futurechange[], int choice)
{
StudentList *nodePtr;

nodePtr=ssnhead->next;
while(nodePtr !=NULL && testIntArray(tempStoreSSN, nodePtr->ssn) == true)
{
nodePtr=nodePtr->next;
}

switch(choice)
{
case 1://Changes first name
strcpy(nodePtr->firstName, futurechange);
break;
case 2://Changes last name
strcpy(nodePtr->lastName, futurechange);
break;
}
}

void StudentInfo::editStudentInfo(int futurechange[])
{
StudentList *nodePtr;

nodePtr=ssnhead->next;

while(testIntArray(tempStoreSSN, nodePtr->ssn) ==true && nodePtr !=NULL)
{
nodePtr=nodePtr->next;
}

for(int count = 0; count<9; count++)
nodePtr->ssn[count]=futurechange[count];
}
bool StudentInfo::testIntArray(int a[], int b[])
{
for(int count=0; count<9; count++)
{
if(a[count] != b[count])
return false;
}
return true;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//mainprogram.cpp

#include <iostream>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include "studentinfo.h"
#include "courses.h"

#define ERROR "\nYou\'ve Entered An Invalid Character!\n"

void displayname(void);
void getStudentInfo(StudentInfo &);
bool changeCase(char [], int);
void getCourseInfo(Courses &);
bool yesorno(void);
int mainMenu(void);
void directions(void);

void search(StudentInfo &);
void insertStudent(StudentInfo &);
void addStudent(StudentInfo &);
void deleteStudent(StudentInfo &);
void editStudent(StudentInfo &);


void main (void)
{
StudentInfo spartans;

int choice;
displayname();
do
{
choice = mainMenu();
switch(choice)
{
case 0: spartans.displayAllStudents();
break;
case 1: insertStudent(spartans);
break;
case 2: //Edit
break;
case 3: search(spartans);
break;
case 4: deleteStudent(spartans);
break;
case 5: cout << "\n\nGOODBYE!!\n\n";
break;
}
}
while(choice != 5);

}


void getCourseInfo(Courses &l)
{
char cname[10];
char cd[25];
char sc[20];
bool execution = true;

cout << "\nEnter The Course Number & Session Number: ";
cin.getline(cname, 11);
execution = changeCase(cname, 3);
if(execution == false)
{
cout << "\nThe Course Has Not Been Entered Into The System ";
cout << "Because Of Input Problems.\n"; directions();
return;
}

cout << "Enter The Course Description: ";
cin.getline(cd, 25);
execution = changeCase(cd,4);
if(execution == false)
{
cout << "\nThe Course Has Not Been Entered Into The System ";
cout << "Because Of Input Problems.\n"; directions();
return;
}

cout << "Enter the Course Schedule: ";
cin.getline(sc, 20);
execution = changeCase(sc, 5);
if(execution == false)
{
cout << "\nThe Course has Not Been Entered Into The System ";
cout << "Because Of Input Problems.\n"; directions();
return;
}

if(execution == true)
l.appendCourse(cname,cd,sc);

}

bool changeCase(char array[], int choice)
{
int elm = strlen(array);
int count = 0;
switch(choice)
{
case 1:
for(count = 0; count < elm; count++)
{
if(count== 0 && isalpha(array[count]))
{
array[count] = toupper(array[count]);
}
else if(isalpha(array[count]))
{
array[count] = tolower(array[count]);
}
else
{
cout << ERROR; return false;

}
}
break;

case 2:
for(count = 0; count < 10; count++)
{
if(isdigit(array[count]));
else
{
cout << ERROR; return false;
}
}
break;

case 3:
for( count = 0; count < elm; count++)
{
if(count <=2)
{
if(isalpha(array[count]))
{
array[count] = toupper(array[count]);
}
else
{
cout << ERROR; return false;
}
}
else if(count == 3)
{
if(isspace(array[count]));

else
{
cout << ERROR; return false;
}
}
else if(count >4 && count <=6)
{
if(isdigit(array[count]));

else
{
cout << ERROR; return false;
}
}
else if(count == 7)
{
if(array[count] == '-');

else
{
cout << ERROR; return false;
}
}
else
{
if(isdigit(array[count]));

else
{
cout << ERROR; return false;
}
}
}
break;

case 4:
for(count = 0; count < elm; count++)
{
if(isalpha(array[count]))
{
if(count == 0)
{
array[count] = toupper(array[count]);
}
else
{
array[count] = tolower(array[count]);
}
}
else if(isspace(array[count]))
{
if(isalpha(array[count+1]))
{
array[count] = toupper(array[count]);
count++;
}
else
{
cout << ERROR; return false;
}
}
else
{
cout << ERROR; return false;
}
}
break;

case 5:
for(int count = 0; count < elm; count++)
{
if(isalpha(array[count]))
{
array[count] = toupper(array[count]);
}
}
break;
}
return true;
}


void directions(void)
{
cout << "\n\nWhen entering data follow the instructions below.\n";
cout << "\t*Enter all names beginning with a capital letter. Ex: Tommy White\n";
cout << "\t*All social security numbers must not have blank spaces or dashes. Ex: 277892345\n";
cout << "\t*Enter \'y\' or \'n\' for all yes or no questions.\n";
cout << "\t*Below is an example of how to input all course information.\n";
cout << "\t\t-Course Number & Session Number: CSC 351-01\n";
cout << "\t\t-Course Description: Linear Algebra\n";
cout << "\t\t-Course Schedule: MWF 0900AM 1000AM\n";
}

bool yesorno(void)
{
char ans;
do
{
cout << "\nEnter Yes or No(Y or N) For The Above Question: ";
cin >> ans;

cin.ignore();

if(tolower(ans) != 'y' && tolower(ans) != 'n')
{
cout << ERROR;
directions();
cout << "\n\nPlease Try Again!!";
}
}
while(tolower(ans) != 'y' && tolower(ans) != 'n');

if(tolower(ans) == 'y')
return true;
else
mainMenu();
return false;

}

int mainMenu(void)
{
int ans;

do
{
cout << "\nMain Menu\n----------\n";
cout << "\t0-Display All Students In The Database\n";
cout << "\t1-Add a Student\n";
cout << "\t-Add a Non-Existing Student\n";
cout << "\t-Register a Non-Existing Student\n";
cout << "\t-Edit a Student\'s Information\n";
cout << "\t-2-Edit a Student\'s Information\n";
cout << "\t\t-Edit a \'Student\'s Courses\n";
cout << "\t\t-Edit a \'Student\'s Personal Information\n";
cout << "\t\t-Register An Existing Student\n";
cout << "\t3-Search For A Student\n";
cout << "\t4-Delete a Student\n";
cout << "\t\t-Delete a Student from The Database\n";
cout << "\t5-Quit\n";
cout << "\nEnter the corresponding number next to the option of your choice: ";
cin >> ans;
cin.ignore();

if(ans != 0 && ans != 1 && ans != 2 && ans != 3 && ans != 4 && ans != 5)
{
cout << ERROR; cout << "\nPlease Try Again!!\n";
}
}
while(ans != 0 && ans != 1 && ans != 2 && ans != 3 && ans != 4 && ans != 5);

return ans;
}

void getStudentInfo(StudentInfo &l)
{
char fname[12];
char lname[12];
//char tempsocial[9];
int social[9];
bool execution = true;

cout << "\nEnter The Student\'s First name: ";
cin.getline(fname, 13);

execution = changeCase(fname, 1);
if(execution == false)
{
cout << "\nThe Student\'s Name Has Not Been Entered Into The System ";
cout << "Because Of Input Problems.\n"; directions();
return;
}

cout << "Enter The Student\'s Last Name: ";
cin.getline(lname, 13);

execution = changeCase(lname,1);
if(execution == false)
{
cout << "\nThe Student\'s Name Has Not Been Entered Into The System ";
cout << "Because Of Input Problems.\n"; directions();
return;
}

cout << "Enter the Student\'s Social Security Number: ";
cin >> social[9];


if(execution == false)
{
cout << "\nThe Student\'s Social Security Number Has Not Been Entered Into The System ";
cout << "Because Of Input Problems.\n"; directions();
return;
}

bool ans;
Courses temp;

cout << "\nWould You Like To Register This Student For A Course? ";
ans = yesorno();
if(ans == true)
{
while(ans == true)
{
getCourseInfo(temp);
cout << "\nWould You Like To Register This Student For Another course? ";
ans = yesorno();
}
l.insertStudent(lname, fname, social);
}
else
{
l.insertStudent(lname, fname, social);

}
}


void addStudent(StudentInfo &n)
{
bool ans;

do
{
getStudentInfo(n);
cout << "\nWould You Like to Add Another Student? ";
ans = yesorno();
}
while (ans == true);
}

void search(StudentInfo &l)
{
bool a, searcher;
int choice, count;

do
{
do
{
cout << "\nEnter 1 to search by last name, or 2 to search ";
cout << "by social security number. " << "\nEnter Here: ";
cin >> choice;

switch(choice)
{
case 1:
char lname[12];
cout << "\nEnter The Student\'s Last Name: ";
cin.getline(lname, 13);
searcher = changeCase(lname, 1);
if(searcher == true)
{
searcher = l.searchBylast(lname);
if(searcher == false)
{
cout << "\nThere is no student by that last name";
cout << " in the database.\n";
}
a = false;
}
else
{
cout << ERROR << "Please Try Again!!\n";
a = true;
}
break;

case 2:
int social[9];
for(count = 0; count < 10; count++)
{
cin >> social[count];
}
searcher = l.searchByssn(social);
if(searcher == false)
{
cout << "\nThere is no student that has that social ";
cout << "security number in the database.\n";
}
a = false;
break;

default:
cout << ERROR; a = true;
}
}
while(a = true);
cout << "\nWould You Like To Try Another Search? ";
a = yesorno();
}
while(a == true);
}

void deleteStudent(StudentInfo &sa)
{
int s[9];
bool a;

cout << "\nEnter the student\'s social security number: ";
&nbs

Add a comment
Know the answer?
Add Answer to:
Write the following program in C++. Review structures, pointers and dynamic memory allocation from CSIT 839....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Assignment Write a menu-driven C++ program to manage a class roster of student names that can...

    Assignment Write a menu-driven C++ program to manage a class roster of student names that can grow and shrink dynamically. It should work something like this (user input highlighted in blue): Array size: 0, capacity: 2 MENU A Add a student D Delete a student L List all students Q Quit ...your choice: a[ENTER] Enter the student name to add: Jonas-Gunnar Iversen[ENTER] Array size: 1, capacity: 2 MENU A Add a student D Delete a student L List all students...

  • Write a menu-driven C++ program to manage a class roster of student names that can grow...

    Write a menu-driven C++ program to manage a class roster of student names that can grow and shrink dynamically. It should work something like this (user input highlighted in blue): Array size: 0, capacity: 2 MENU A Add a student D Delete a student L List all students Q Quit ...your choice: a[ENTER] Enter the student name to add: Jonas-Gunnar Iversen[ENTER] Array size: 1, capacity: 2 MENU A Add a student D Delete a student L List all students Q...

  • You are asked to build and test the following system using Java and the object-oriented concepts ...

    You are asked to build and test the following system using Java and the object-oriented concepts you learned in this course: Project (20 marks) CIT College of Information technology has students, faculty, courses and departments. You are asked to create a program to manage all these information's. Create a class CIT to represents the following: Array of Students, each student is represented by class Student. Array of Faculty, each faculty is represented by class Faculty. Array of Course, each course...

  • Write a MIPS assembly language program that uses dynamic memory allocation to create and manage a...

    Write a MIPS assembly language program that uses dynamic memory allocation to create and manage a linked list data structure. Gives the user the following options:                         1. To create and add the first node to a linked list.          2. To add a single node to the pre-existing linked list.             The list must already exist before a new node can be added.            The nodes should be maintained in ascending order based on the data value within the nodes...

  • Write C++ program (studentsGpa.cpp) uses dynamic allocation to create an array of strings. It asks the...

    Write C++ program (studentsGpa.cpp) uses dynamic allocation to create an array of strings. It asks the user to enter a number and based on the entered number it allocates the array size. Then based on that number it asks the user that many times to enter student’s names. What you need to do:  Add another array of doubles to store the gpa of each student as you enter them  You need to display both the student’s name and...

  • Design and code a JAVA program called ‘Grades’. ? Your system should store student’s name, and...

    Design and code a JAVA program called ‘Grades’. ? Your system should store student’s name, and his/her course names with grades. ? Your system should allow the user to input, update, delete, list and search students’ grades. ? Each student has a name (assuming no students share the same name) and some course/grade pairs. If an existing name detected, user can choose to quit or to add new courses to that student. ? Each student has 1 to 5 courses,...

  • CS 241 Program 03 Due: Thursday, October 18th Main topics: Arrays& Pointers Memory allocation ram Specification:...

    CS 241 Program 03 Due: Thursday, October 18th Main topics: Arrays& Pointers Memory allocation ram Specification: A stack is a container that can be defined in terms of an array where all adds are preformed at the end of the sequence of existing values, and all removes are also preformed at end of the sequence of existing values. An empty stack is one that has no existing values in the array at all. We use the notion of top of...

  • In C++, write a complete program that receives a series of student records from the keyboard...

    In C++, write a complete program that receives a series of student records from the keyboard and stores them in three parallel arrays named studentID and courseNumber and grade. All arrays are to be 100 elements. The studentID array is to be of type int and the courseNumber and grade arrays are to be of type string. The program should prompt for the number of records to be entered and then receive user input on how many records are to...

  • GPA calculator: Assume the user has a bunch of courses they took, and need to calculate...

    GPA calculator: Assume the user has a bunch of courses they took, and need to calculate the overall GPA. We will need to get the grade and number of units for each course. It is not ideal to ask how many courses they took, as they have to manually count their courses. Programming is about automation and not manual work. We will create a textual menu that shows 3 choices. 1. Enter course grade and units. 2. Show GPA. 3....

  • In JAVA please! Write program for exercises You will write a Graphical User Interface(GUI) application to manage student...

    In JAVA please! Write program for exercises You will write a Graphical User Interface(GUI) application to manage student information system. The application should allow: 1. Collect student information and store it in a binary data file. Each student is identified by an unique ID. The user should be able to view/edit an existing student. Do not allow student to edit ID. 2. Collect Course information and store it in a separate data file. Each course is identified by an unique...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT