Question
Please help, provide source code in c++(photos attached)


develop a class called Student with the following protected data:

name (string), id (string), units (int), gpa (double).

Public functions include:

default constructor, copy constructor, overloaded = operator, destructor, read() to read data into it, print() to print its data, get_name() which returns name and get_gpa() which returns the gpa.

Derive a class called StuWorker (for student worker) from Student with the following added data:

hours (int for hours assigned per week), hourlyRate (double) and the following public functions in addition to those it inherits from Student:

default constructor, copy constructor, overloaded = operator, destructor, read() and print(). read() and print() will call base read and print for the common data and read and print stuWorker's additional data.

In main(), create an array of 20 Student pointers and keep asking the user if he or she wants to add a Student. If the answer is 'y' or 'Y', ask if the student being added is a student worker. If it is, allocate memory for a StuWorker and if not, allocate memory for a Student, and in each case, add it to the array of Student pointers.

For each Student or StuWorker dynamically created, call the object's read() function to read data from the user. This should be okay since a student worker is a Student, too and depending on the type of object that's been created, the correct class's read() is called (this is the polymorphism part).

Create a vector of Student pointers. After each Student object is created and data read into it, push it into the vector. Continue as long as the user answers with 'y' or 'Y' to "Add student?" question.

When, all the objects are allocated and added to vector, print the list through the array of Student pointers. Again, each object should be printed correctly, depending on whether it's a Student or StuWorker. As you print each student, if it happens to be a student worker, the hours per week and hourly rate should also show up, in addition to Student data, if you have declared the read and print member functions correctly.

Then, pass the vector of Student objects to a sort() function to sort the Students on their name in ascending order. To traverse the vector, you will be using its iterator. Note, that you're passing the vector and not the array of pointers to sort();

Then, print the list again through the same array of pointers as before. It should print the list sorted, now. However, you will notice that sort() has made all objects Student, whether they were Student or StuWorker. That's because when copying from a StuWorker into Student or vice versa, StuWorker's become Student which they are, anyway.

Display the average GPA of all students by getting each GPA through the vector using its iterator.

Finally, read a name to search for and pass the Students vector and the entered name to a binary search function that returns the index of the Student in the vector, if it finds it or -1, if it doesn't. Print the search result in main.

please lmk if images arent clear

thank you :)

Add new student? [y/n]: y Is this a student worker? [Y/N]: y Enter student name: Sally Lara Enter student id: 101 Enter units
Add new student? [y/n]: n Name: Sally Lara ID: 101 Units completed: 12 GPA: 3.1 Hours per week: 15 Hourly rate: 15.5 Name: Fr
Name: Pam Taylor ID 105 Units completed: 20 GPA: 3 Name: Sally Lara ID: 101 Units completed: 12 GPA: 3.1 Average GPA: 3.14 En
Add new student? [y/n]: y Is this a student worker? [Y/N]: y Enter student name: Sally Lara Enter student id: 101 Enter units completed by the student: 12 Enter student's GPA: 3.1 Enter hours assgined per week: 15 Enter hourly rate: 15.50 Add new student? [y/n]: y Is this a student worker? [Y/N]: n Enter student name: Fred Gold Enter student id: 102 Enter units completed by the student: 24 Enter student's GPA: 3.3 Add new student? [y/n]: y Is this a student worker? [Y/N]: y Enter student name: Greg Gome z Enter student id: 103 Enter units completed by the student: 15 Enter student's GPA: 2.9 Enter hours assgined per week: 10 Enter hourly rate: 13.75 dd new student? [y/n]: y
Add new student? [y/n]: n Name: Sally Lara ID: 101 Units completed: 12 GPA: 3.1 Hours per week: 15 Hourly rate: 15.5 Name: Fred Gold ID: 102 Units completed: 24 GPA: 3.3 Name: Greg Gomez ID: 103 Units completed: 15 GPA: 2.9 Hours per week: 10 Hourly rate: 13.75 Name: Ed Stevens ID: 104 Units completed: 18 GPA: 3.4 Name: Pam Taylon ID: 105 Units completed: 20 GPA: 3 Hours per week: 15 Hourly rate: 17.25 Sorted Students List: Name: Ed Stevens ID: 104 Units completed: 18 GPA: 3.4 Name: Fred Gold ID: 102 Units completed: 24 GPA: 3.3 Name: Greg Gomez ID: 103 Units completed: 15 GPA: 2.9
Name: Pam Taylor ID 105 Units completed: 20 GPA: 3 Name: Sally Lara ID: 101 Units completed: 12 GPA: 3.1 Average GPA: 3.14 Enter the name of the student to search for: Pam Taylor Student was found at index 3 Press any key to continue._
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Public VoTd inchemert Gcal C)

Add a comment
Know the answer?
Add Answer to:
Please help, provide source code in c++(photos attached) develop a class called Student with the following protected...
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
  • Define a class called Student with ID (string), name (string), units (int) and gpa (double). Define...

    Define a class called Student with ID (string), name (string), units (int) and gpa (double). Define a constructor with default values to initialize strings to NULL, unit to 0 and gpa to 0.0. Define a copy constructor to initialize class members to those of another Student passed to it as parameters. Overload the assignment operator (=) to assign one Student to another. Define a member function called read() for reading Student data from the user and a function called print()...

  • I need code in java The Student class: CODE IN JAVA: Student.java file: public class Student...

    I need code in java The Student class: CODE IN JAVA: Student.java file: public class Student {    private String name;    private double gpa;    private int idNumber;    public Student() {        this.name = "";        this.gpa = 0;        this.idNumber = 0;    }    public Student(String name, double gpa, int idNumber) {        this.name = name;        this.gpa = gpa;        this.idNumber = idNumber;    }    public Student(Student s)...

  • For Python 3.7+. TEST THE CODE WITH THE FOLLOWING GLOBAL CODE AFTER YOU'RE DONE: print('\nStart of...

    For Python 3.7+. TEST THE CODE WITH THE FOLLOWING GLOBAL CODE AFTER YOU'RE DONE: print('\nStart of A2 Student class demo ') s1 = Student('David Miller', major = 'Hist',enrolled = 'y', credits = 0, qpoints = 0) s2 = Student('Sonia Fillmore', major = 'Math',enrolled = 'y', credits = 90, qpoints = 315) s3 = Student('A. Einstein', major = 'Phys',enrolled = 'y', credits = 0, qpoints = 0)          s4 = Student('W. A. Mozart', major = 'Mus',enrolled = 'n', credits = 29, qpoints...

  • Hello I need help fixing my C++ code. I need to display in the console the...

    Hello I need help fixing my C++ code. I need to display in the console the information saved in the file as well have the content saved in the file output in a fixed position like the screenshot. Thanks. CODE #include<iostream> #include<fstream> #include<iomanip> using namespace std; //main function int main() {    //variable to store student id    int id;       //variables to store old gpa(ogpa), old course credits(occ), new course credits(ncc), current gpa(cur_gpa), cumulative gpa(cum_gpa)    float ogpa,...

  • The homework assignment is to write a fee invoice using C. It must follow the guidelines posted i...

    The homework assignment is to write a fee invoice using C. It must follow the guidelines posted in the question and run as the sample run given. Here is the question and sample run below Please read the sample runs carefully as this is quite different from the previous projects. In this project, the student can take as many courses as permitted. The list of courses to take are listed below. This time there is no restriction on the total...

  • Written in C, if you are able to provide comments so I can learn as I...

    Written in C, if you are able to provide comments so I can learn as I practice that would be amazing! Thank you! Learning Outcomes: Selection structures and Loops Read carefully before you start coding! At Valence community college, a student can’t take more than 3 courses under the constraint of having no more than 7 credit hours. The purpose of this assignment is to construct a fee invoice for a student. This requires the input of Student’s id as...

  • c++ implement a student class Determine the final scores, letter grades, and rankings of all students...

    c++ implement a student class Determine the final scores, letter grades, and rankings of all students in a course. All records of the course will be stored in an input file, and a record of each student will include the first name, id, five quiz scores, two exam scores, and one final exam score. For this project, you will develop a program named cpp to determine the final scores, letter grades, and rankings of all students in a course. All...

  • Write a C++ program for the instructions below. Please read the instructions carefully and make sure they are followed correctly.   and please put comment with code! Problem:2 1. Class Student Create...

    Write a C++ program for the instructions below. Please read the instructions carefully and make sure they are followed correctly.   and please put comment with code! Problem:2 1. Class Student Create a "Hello C++! I love CS52" Program 10 points Create a program that simply outputs the text Hello C++!I love CS52" when you run it. This can be done by using cout object in the main function. 2. Create a Class and an Object In the same file as...

  • Rework this project to include a class. As explained in class, your project should have its...

    Rework this project to include a class. As explained in class, your project should have its functionalities moved to a class, and then create each course as an object to a class that inherits all the different functionalities of the class. You createclass function should be used as a constructor that takes in the name of the file containing the student list. (This way different objects are created with different class list files.) Here is the code I need you...

  • ASSIGNMENT DUE DATE GOT PUSHED BACK TO LATE THIS WEEK. PLEASE READ COMMENTS AND CODE BEFORE...

    ASSIGNMENT DUE DATE GOT PUSHED BACK TO LATE THIS WEEK. PLEASE READ COMMENTS AND CODE BEFORE ANSWERING CODING SECTIONS HW07 #Q1-Q5 HW08 #Q1-Q2 // READ BEFORE YOU START: // Please read the given Word document for the project description with an illustrartive diagram. // You are given a partially completed program that creates a list of students for a school. // Each student has the corresponding information: name, standard, and a linked list of absents. // Please read the instructions...

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