Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(language:C++) A class allows a group of one or more member objects to have a se

ID: 3734430 • Letter: #

Question

(language:C++)

A class allows a group of one or more member objects to have a series of common characteristics and functions. Basic capabilities include updating, creating, destroying class objects

Create a class (student) that contains the member characteristics:

Student ID (string)

Student Last Name (string)

Student First Name (string)

GPA (float)

Number of enrolled classes (integer)

The class functions are:

DisplayStudent - display member fields’ values from within this class member function

SetALL - strings, float and integer passed to function setting the appropriate field in class

SetID – string passed to class member function to set Student ID

SetLastName – string passed to class member function to set Student Last Name

SetFirstName – string passed to class member function to set Student First Name

SetGPA – float value passed to class member function to set GPA

SetClasses – integer value passed to class member function to set Number of enrolled classes

GetID – returns string Student ID

GetLastName – returns string Student Last Name

GetFirstName – returns string Student First Name

GetGPA – returns float GPA

GetClasses – return integer value of enrolled classes

Constructor – set default values for member

Application will:

a)Create class members by reading in attached data file into class. (Array of class members?)----data file:

AF101 Smith Zachery 3.2 4
HJ389 Cula Drak 3.3 2
KL209 Stein Franklin 4.0 4
LL309 DeMann Alexandra 3.5 3
ZZ009 Wilkins Jonathan 2.5 2
NM210 Williams Judith 3.0 4
JK111 Grimm Benjamin 4.0 3
KK101 Parker Pete 3.75 2
MN101 Storm Susan 3.8 3
NB100 Doome D.R. 4.0 4
AA101 Mousee Minnie 2.5 1
JH008 Ducke Don 2.0 2

b.Store all class members in an array of a maximum size of 20

c)Allow the user the following options:

1)Display each class member’s individual characteristics (Student ID, Last Name, First Name, GPA, number of enrolled classes)

2)Find one particular student records by the array index

3)Change any of the fields for a student (select student by its array index)

1)Student ID

2)Student Last Name

3)Student First Name

4)GPA

5)Number of enrolled classes

6)Add a new student record subject to the maximum size of the index

7)Quit this application

Output Example:

1 - Display ALL Records

2 - Add a New Record to the Maximum of 6 Records

3 - Change an Existing Record's Fields

4 - Find One Record

5 - Quit

        Enter an Option (1 to 5): 1

Display the students' data:

Student ID: AF101

Smith, Zachery H.

4 Classes Taken This Semester

Current GPA is 3.2

Student ID: HJ389

Jones, Alias T.

2 Classes Taken This Semester

Current GPA is 3.3

Student ID: KL209

Luzer, Emma P.

4 Classes Taken This Semester

Current GPA is 4

Student ID: LL309

Beans, Hill O.

3 Classes Taken This Semester

Current GPA is 2.5

Hit Any Key to continue...

1 - Display ALL Records

2 - Add a New Record to the Maximum of 6 Records

3 - Change an Existing Record's Fields

4 - Find One Record

5 - Quit

        Enter an Option (1 to 5): 2

           

Record # 7 of 10

1 of 5 - Enter Student ID: SS782

2 of 5 - Enter Student Last Name: Francis

3 of 5 - Enter Student First Name: Alanna P.

4 of 5 - Enter Student Grade Point Average: 3.7

5 of 5 - Enter Number of Class Enrolled for Student ID SS782: 3

1 - Display ALL Records

2 - Add a New Record to the Maximum of 7 Records

3 - Change an Existing Record's Fields

4 - Find One Record

5 - Quit

        Enter an Option (1 to 5): 3

Enter an Index (0 to 6): 1

Student ID: HJ389

Jones, Alias T.

2 Classes Taken This Semester

Current GPA is 3.30

Change A Field Value

1 - Student ID

2 - Student Last Name

3 - Student First Name

4 - Student GPA

5 - Number of Enrolled Classes

        Enter Option (1 to 5): 5

Enter Number of Class Enrolled for Student ID SS782: 2

1 - Display ALL Records

2 - Add a New Record to the Maximum of 7 Records

3 - Change an Existing Record's Fields

4 - Find One Record

5 - Quit

        Enter an Option (1 to 5): 4

Enter an Index (0 to 6): 2

Student ID: KL209

Luzer, Emma P.

4 Classes Taken This Semester

Current GPA is 4.00

Hit Any Key to continue...

Explanation / Answer

Source Code:-
-------------------------
#include<iostream>
#include<iomanip>
#include<fstream>
#include<stdlib.h>
#include<string.h>
using namespace std;
class Student_Record
{
public:
char Student_ID[100];
char LastName[100];
char FirstName[100];
float GPA;
int enrolled_classes;
int size,index;
public:
Student_Record()
{
index=12;
size=12;
}
public:
void DisplayStudent();
void SetID(char id[]);
void SetLastName(char lastname[]);
void SetFirstName(char firstname[]);
void SetGPA(float gpa);
void SetClasses(int noof_Classes);
char *GetID();
char *GetLastName();
char *GetFirstName();
float GetGPA();
int FindRecord(char id[]);
void display_oneRecord(int);
void UpdateNewRecord(int);
}array[20];
void Student_Record::DisplayStudent()
{
cout<<" --------------------------------------------------------"<<endl;
cout<<"ID FirstName LastName"<<setw(15)<<"GPA"<<setw(15)<<"Noofclasses"<<endl;
cout<<"--------------------------------------------------------"<<endl;
for(int i=1;i<=size;i++)
{
cout<<array[i].Student_ID<<setw(15)<<array[i].FirstName<<setw(15)<<array[i].LastName<<setw(15)<<array[i].GPA<<setw(15)<<array[i].enrolled_classes<<endl;
}
cout<<endl;
}
void Student_Record::UpdateNewRecord(int index)
{
int choice,n;
char fname[100],lname[100],id[100];
float gpa;
cout<<" -----------------------"<<endl;
cout<<"***** Update Menu *****"<<endl;
cout<<"-----------------------"<<endl;
cout<<" 1.Update Student ID"<<endl;
cout<<" 2.Update FirstName"<<endl;
cout<<" 3.Update LastName"<<endl;
cout<<" 4.Update GPa"<<endl;
cout<<" Please Choose Any Option to Update:"<<endl;
cin>>choice;
switch(choice)
{
case 1:
cout<<" Please Enter New StudentId"<<endl;
cin>>id;
strcpy(array[index].Student_ID,id);
cout<<" Updated Successfully"<<endl;
break;
case 2:
cout<<" Please Enter New FirstName"<<endl;
cin>>fname;
strcpy(array[index].FirstName,fname);
cout<<" Updated Successfully"<<endl;
break;
case 3:
cout<<" Please Enter New LastName"<<endl;
cin>>lname;
strcpy(array[index].LastName,lname);
cout<<" Updated Successfully"<<endl;
break;
case 4:
cout<<" Please Enter the GPA:"<<endl;
cin>>GPA;
array[index].GPA=GPA;
cout<<" Updated Successfully"<<endl;
break;
default:
cout<<" Wrong Option try again"<<endl;
}
}
int Student_Record::FindRecord(char Studentid[])
{
for(int i=1;i<=size;i++)
{
if(!strcmp(Studentid,array[i].Student_ID))
{
return i;
}
}
return -1;
}
void Student_Record::SetID(char idvalue[])
{
strcpy(Student_ID,idvalue);
}
void Student_Record::SetFirstName(char firstname[])
{
strcpy(array[index].FirstName,firstname);
}
void Student_Record::SetLastName(char lastname[])
{
strcpy(array[index].LastName,lastname);
}
void Student_Record::SetGPA(float gpa)
{
array[index].GPA=gpa;
}
void Student_Record::SetClasses(int classes)
{
array[index].enrolled_classes=classes;
}
void Student_Record::display_oneRecord(int pos)
{
cout<<" --------------------------------------------------------"<<endl;
cout<<"ID FirstName LastName"<<setw(15)<<"GPA"<<setw(15)<<"Noofclasses"<<endl;
cout<<"--------------------------------------------------------"<<endl;
cout<<array[pos].Student_ID<<setw(15)<<array[pos].FirstName<<setw(15)<<array[pos].LastName<<setw(15)<<array[pos].GPA<<setw(15)<<array[pos].enrolled_classes<<endl;
}
int main()
{
Student_Record obj;
int option,index,pos;
char id[100],firstname[100],lastname[100];
float gpa;
int classes;
ifstream myfile;
myfile.open("StudentData.txt");
for(int i=1;i<=obj.size;i++)
{
myfile>>array[i].Student_ID;
myfile>>array[i].FirstName;
myfile>>array[i].LastName;
myfile>>array[i].GPA;
myfile>>array[i].enrolled_classes;
Student_Record obj;
}
while(true){
cout<<" ------------------------------------------"<<endl;
cout<<"************Student Records***************"<<endl;
cout<<"------------------------------------------"<<endl;
cout<<" 1 - Display ALL Records"<<endl;
cout<<" 2 - Add a New Record to the Maximum of 6 Records"<<endl;
cout<<" 3 - Change an Existing Record's Fields"<<endl;
cout<<" 4 - Find One Record"<<endl;
cout<<" 5 - Quit"<<endl;
cout<<" Please Select any option"<<endl;
cin>>option;
switch(option)
{
case 1:
obj.DisplayStudent();
break;
case 2:
obj.index++;
cout<<" Please Enter Student Id:"<<endl;
cin>>id;
strcpy(array[index].Student_ID,id);
obj.SetID(id);
cout<<" Please Enter the Student FirstName:"<<endl;
cin>>firstname;
strcpy(array[index].FirstName,firstname);
obj.SetFirstName(firstname);
cout<<" Please Enter the Student LastName"<<endl;
cin>>lastname;
strcpy(array[index].LastName,lastname);
obj.SetLastName(lastname);
cout<<" Please Enterthe GPa"<<endl;
cin>>gpa;
array[index].GPA=gpa;
obj.SetGPA(gpa);
cout<<" Please Enterthe Noof Classes"<<endl;
cin>>classes;
array[index].enrolled_classes=classes;
obj.SetClasses(classes);
cout<<" New Student Details Added Successfully"<<endl;
break;
case 3:
cout<<" Please Enter the Student ID to Update"<<endl;
cin>>id;
pos=obj.FindRecord(id);
if(pos!=-1)
{
obj.UpdateNewRecord(pos);
}
else
{
cout<<"The Record is Not Found"<<endl;
}
break;
case 4:
cout<<" Please Enter the Student Id to Search"<<endl;
cin>>id;
pos=obj.FindRecord(id);
if(pos!=-1)
{
obj.display_oneRecord(pos);
}
else
{
cout<<"The Record is Not Found"<<endl;
}
break;
case 5:
exit(0);
default:
cout<<"wrong Option"<<endl;
}
}
}


Sample Output:-
--------------------------

------------------------------------------
************Student Records***************
------------------------------------------

1 - Display ALL Records

2 - Add a New Record to the Maximum of 6 Records

3 - Change an Existing Record's Fields

4 - Find One Record

5 - Quit

Please Select any option
1

--------------------------------------------------------
ID FirstName LastName GPA Noofclasses
--------------------------------------------------------
AF101 Smith Zachery 3.2 4
HJ389 Cula Drak 3.3 2
KL209 Stein Franklin 4 4
LL309 DeMann Alexandra 3.5 3
ZZ009 Wilkins Jonathan 2.5 2
NM210 Williams Judith 3 4
JK111 Grimm Benjamin 4 3
KK101 Parker Pete 3.75 2
MN101 Storm Susan 3.8 3
NB100 Doome D.R. 4 4
AA101 Mousee Minnie 2.5 1
JH008 Ducke Don 2 2


------------------------------------------
************Student Records***************
------------------------------------------

1 - Display ALL Records

2 - Add a New Record to the Maximum of 6 Records

3 - Change an Existing Record's Fields

4 - Find One Record

5 - Quit

Please Select any option
4

Please Enter the Student Id to Search
123
The Record is Not Found

------------------------------------------
************Student Records***************
------------------------------------------

1 - Display ALL Records

2 - Add a New Record to the Maximum of 6 Records

3 - Change an Existing Record's Fields

4 - Find One Record

5 - Quit

Please Select any option
4

Please Enter the Student Id to Search
AA101

--------------------------------------------------------
ID FirstName LastName GPA Noofclasses
--------------------------------------------------------
AA101 Mousee Minnie 2.5 1

------------------------------------------
************Student Records***************
------------------------------------------

1 - Display ALL Records

2 - Add a New Record to the Maximum of 6 Records

3 - Change an Existing Record's Fields

4 - Find One Record

5 - Quit

Please Select any option
3

Please Enter the Student ID to Update
AA101

-----------------------
***** Update Menu *****
-----------------------

1.Update Student ID

2.Update FirstName

3.Update LastName

4.Update GPa

Please Choose Any Option to Update:
3

Please Enter New LastName
KOOTHADA

Updated Successfully

------------------------------------------
************Student Records***************
------------------------------------------

1 - Display ALL Records

2 - Add a New Record to the Maximum of 6 Records

3 - Change an Existing Record's Fields

4 - Find One Record

5 - Quit

Please Select any option
1

--------------------------------------------------------
ID FirstName LastName GPA Noofclasses
--------------------------------------------------------
AF101 Smith Zachery 3.2 4
HJ389 Cula Drak 3.3 2
KL209 Stein Franklin 4 4
LL309 DeMann Alexandra 3.5 3
ZZ009 Wilkins Jonathan 2.5 2
NM210 Williams Judith 3 4
JK111 Grimm Benjamin 4 3
KK101 Parker Pete 3.75 2
MN101 Storm Susan 3.8 3
NB100 Doome D.R. 4 4
AA101 Mousee KOOTHADA 2.5 1
JH008 Ducke Don 2 2


------------------------------------------
************Student Records***************
------------------------------------------

1 - Display ALL Records

2 - Add a New Record to the Maximum of 6 Records

3 - Change an Existing Record's Fields

4 - Find One Record

5 - Quit

Please Select any option
2

Please Enter Student Id:
VENKY@4547

Please Enter the Student FirstName:
VENKANNA

Please Enter the Student LastName
KOOTHADA

Please Enterthe GPa
89.0

Please Enterthe Noof Classes
5

New Student Details Added Successfully

------------------------------------------
************Student Records***************
------------------------------------------

1 - Display ALL Records

2 - Add a New Record to the Maximum of 6 Records

3 - Change an Existing Record's Fields

4 - Find One Record

5 - Quit

Please Select any option
1

--------------------------------------------------------
ID FirstName LastName GPA Noofclasses
--------------------------------------------------------
AF101 Smith Zachery 3.2 4
HJ389 Cula Drak 3.3 2
KL209 Stein Franklin 4 4
LL309 DeMann Alexandra 3.5 3
ZZ009 Wilkins Jonathan 2.5 2
NM210 Williams Judith 3 4
JK111 Grimm Benjamin 4 3
KK101 Parker Pete 3.75 2
MN101 Storm Susan 3.8 3
NB100 Doome D.R. 4 4
AA101 Mousee KOOTHADA 2.5 1
JH008 Ducke Don 2 2


------------------------------------------
************Student Records***************
------------------------------------------

1 - Display ALL Records

2 - Add a New Record to the Maximum of 6 Records

3 - Change an Existing Record's Fields

4 - Find One Record

5 - Quit

Please Select any option
5