PROGRAM:
#include <iostream> // To input and output operation from
console.
#include <list> // STL list , to store object of structure
Records
#include <string> // To perform operation related string like
comparison,etc.
#include <iterator> // To iterate the list.
using namespace std;
struct Records // Define structure with two attributes
{
string class_name;
char grade;
};
class Student // Define class
{
public:
Student(string& name) // Define constructor
{
this->st_name=name; // Initialize the name.
numClassesTaken = 0; // Initially set the total number of class
taken by student as zero.
}
void printRecords(); // Declare method to print all records about
student.
char gradeForClass(string& cl_name); // To find the grade of
given class.
string standing(); // To find the standing of student/
void addClass(string&, char); // To add class.
private:
int numClassesTaken; // To keep the track of clssses
string st_name; /// To store name of student
list<Records> st_records; // Declare list with type of
structure named Records.
};
void Student::printRecords()
{
cout << "\nName Of Student : " << st_name; // Printing
all details of student.
cout << "\nNumber of Classes taken : " <<
numClassesTaken;
for (const Records& record : st_records) // Iterate the
list
{
cout << "\nClass name : " << record.class_name; //
Print each class name
cout << "\nGrade : " << record.grade; // Peint grade
for that class
}
}
string Student::standing()
{
int classesTaken = st_records.size(); // Caculate number of class
attend by student
if (classesTaken >= 0 && classesTaken <= 3) // Check
condition to find standing of student
{
return "Freshman";
}
else if (classesTaken >= 4 && classesTaken <= 6) //
Check condition to find standing of student
{
return "Sophomore";
}
else if (classesTaken >= 7 && classesTaken <= 10) //
Check condition to find standing of student
{
return "Junior";
}
else
{
return "Senior"; // If student attend more than 10 class.
}
}
char Student::gradeForClass(string &cl_name)
{
for (const Records& record : st_records) // Iterate the
list.
{
if (cl_name.compare(record.class_name) == 0) // Compare the given
class with each object.
{
return record.grade; // If match the class return grade.
}
}
return 'F'; // Otherwise return F as grade.
}void Student::addClass(string & class_name,char grade
)
{
int flag = 0; // Initially set the flag as zero.
for (const Records& record : st_records) // Iterate the
list.
{
if (record.class_name.compare(class_name) == 0) // If class name
match with previouslly entered class name
{
flag = 1; // Set flag as zero
break; // Break the loop
}
}
if (flag != 1) // If class is not taken previouslly.
{
numClassesTaken++; // Inrement number of class taken.
struct Records r; // Make object of structure.
r.class_name = class_name; // Initialize the name of class.
r.grade = grade; // Initialize the grade of class.
list<Records>::iterator it;
it = st_records.end(); // Take the address of last object.
st_records.insert(it, r); // Insert at the end of list.
}
else
{ // If class is already in list, print this message.
cout << "\n" << class_name << " is taken already!
Please enter other class.";
}
}
int main()
{
string name, classname;
char grade;
cout << "Enter Name of Student : ";
getline(cin,name); // Taking name of student
Student student(name); /// Creating object of class student
cout << "\nDo you want to add class : \n Yes -> y\n No
-> n\n (y/n)?";
cin >> name; // Read choice
while (name.compare("y") == 0) // Iterate the loop untill user like
to stop.
{
cout << "\nEnter name of class : "; // get details
cin >> classname;
cout << "\nEnter Grade : ";
cin >> grade;
student.addClass(classname, grade); /// Call the function to add
class in list
cout << "\nDo you want to add class again :\n Yes -> y\n
No -> n\n (y/n)?";
cin >> name; // Again asked to enter other class.
}
cout << "\n################# YOUR DETIALS
#################\n";
student.printRecords(); // Print the details by calling the
function
cout << "\nYour standing : " << student.standing(); //
Find the standing of student.
cout <<
"\n\n####################################################\n";
cout << "\n Do you want to find grade of any class?\n Yes
-> y\n No -> n\n (y/n)";
cin >> name; // Read choice of student to find the grade of
any class.
while(name.compare("y") == 0) // Iterate the loop untill user like
to stop.
{
cout << "\nPlease enter class name : ";
cin >> classname; // Read the class name and pass as
parameter in function call
cout << "\nYour Grade in class " << classname <<
" is " << student.gradeForClass(classname); // print the
grade of class
cout << "\n Do you want to find grade of any class again?\n
Yes -> y\n No -> n\n (y/n)";
cin >> name; // Again ask to find.
}
cout << "\n Thank you!"; // Print the message
return 0;
}
OUTPUT:
SCREENSHOT OF PROGRAM:
please help Write a simple program with Student class having STL list of Record's structure as...
Please provide the code for the last part(client side program). yes i have all the class implementations. ``` person.h #ifndef PERSON_H #define PERSON_H #include <string> using namespace std; class person { public: person(); string getname() const; string getadd() const; string getemail() const; string getphno() const; string toString() const; private: string name; string add; string email; string phno; }; ```person.cpp #include "person.h" person::person() { name = "XYZ"; add="IIT "; email="%%%%"; phno="!!!!!"; } string person::getname() const { return name; } string person::getadd()...
Last picture is the tester program! In this Assignment, you will create a Student class and a Faculty class, and assign them as subclasses of the superclass UHPerson. The details of these classes are in the UML diagram below: UHPerson - name : String - id : int + setName(String) : void + getName(): String + setID(int) : void + getID(): int + toString(): String Faculty Student - facultyList : ArrayList<Faculty - rank: String -office Hours : String - studentList...
A teacher wants to create a list of students in her class. Using the existing Student class in this exercise. Create a static ArrayList called classList that adds a student to the classList whenever a new Student is created. In the constructor, you will have to add that Student to the ArrayList. Coding below was given to edit and use public class ClassListTester { public static void main(String[] args) { //You don't need to change anything here, but feel free...
Question 1 (4 mark): Implement a program with two classes according to the following UML diagram: College -firstLab Student: StudentAccount - secondLab Student: StudentAccount +main (String (1) : void +College (String, String, int, int) : +printStudents(): void contains StudentAccount -name: String -studentNumber: int StudentAccount (String, int): +getName(): String +getStudentNumber(): int 2 REQUIREMENTS • The constructor College (String, String, int, int) shall create two component objects of type StudentAccount, i.e., the first lab student and the second lab student, and initialize...
You will create a class to keep student's information: name, student ID, and grade. The program will have the following functionality: - The record is persistent, that is, the whole registry should be saved on file upon exiting the program, and after any major change. - The program should provide the option to create a new entry with a student's name, ID, and grade. - There should be an option to lookup a student from his student ID (this will...
Please help!! I am supposed to write a program in C++ about student & grades. Needs to have two functions that sorts students letter grade, and another one to sort Students name in your student’s record project. Remember, to add necessary parameters and declaration in main to call each function properly. Order of functions call are as follow Read Data Find Total Find average Find letter grade Call display function Call sort letter grade function Call display function Call sort...
Greetings, everybody I already started working in this program. I just need someone to help me complete this part of the assignment (my program has 4 parts of code: main.cpp; Student.cpp; Student.h; StudentGrades.cpp; StudentGrades.h) Just Modify only the StudentGrades.h and StudentGrades.cpp files to correct all defect you will need to provide implementation for the copy constructor, assignment operator, and destructor for the StudentGrades class. Here are my files: (1) Main.cpp #include <iostream> #include <string> #include "StudentGrades.h" using namespace std; int...
Please help. I need a very simple code. For a CS 1 class. Write a program in Java and run it in BlueJ according to the following specifications: The program reads a text file with student records (first name, last name and grade). Then it prompts the user to enter a command, executes the command and loops. The commands are the following: "printall" - prints all student records (first name, last name, grade). "firstname name" - prints all students with...
a c++ program (The Person, Student, Employee, Faculty, and Staff classes) Design a class named Person and its two subclasses named Student and Employee. Make Faculty and Staff subclasses of Employee. A person has a name, address, phone number, and email address. A student has a class status (freshman, sophomore, junior, or senior). Define the status as a constant. An employee has an office, salary, and date hired. Use the MyDate classto create an object for date hired. A faculty...
1. Do the following a. Write a class Student that has the following attributes: - name: String, the student's name ("Last, First" format) - enrollment date (a Date object) The Student class provides a constructor that saves the student's name and enrollment date. Student(String name, Date whenEnrolled) The Student class provides accessors for the name and enrollment date. Make sure the class is immutable. Be careful with that Date field -- remember what to do when sharing mutable instance variables...