Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

USING C++ Goal: a program to manage student records You are asked to implement a program to manage Student records of the following form: class

USING C++

Goal: a program to manage student records

You are asked to implement a program to manage Student records of the following form:

class Student { private: std::string name_; int number_; std::vector grades_; const int num_courses_; // You need to implement the following four methods static std::string gen_name() { } // To do  static int gen_number() { } // To do  static int gen_grade() { } // To do  double compute_average() { } // To do  public: Student(const std::string& name, int number) : name_(name), number_(number), num_courses_(5) { for (int i=0; ifriend std::ostream& operator<<(std::ostream& os, const Student& s) { os << "Name = " << s.name_ << ", Number = " << s.number_; return os; } void print_grades(std::ostream& os) const { for (int i=0; i 

Number of students will be specified at runtime

The number of students to be stored in the system will be specified at runtime via commandline arguments. The program will take 1 argument whose value will indicate the number of students to stored in the system. The following call, for example, will store 77students in the system.

$ student-record 7 ...

Student records will be initialized with random values

Names, numbers and grades will be set to random values with the following constraints:

A name is a random string (a-zA-Z0-9) between 6 and 12 characters long;

A number is a random integer between 201100000 and 201600000; and

A grade is a random integer between 70 and 100.

Note that each student stores only 5 grades.

Required functionality

The program will store students in std::vector and will implement the following functionality:

Print student records;

Print student records sorted by name (ascending order);

Print student records sorted by average grade (ascending order); and

Print the student record with the highest average grade (and print average values).

Average values may be floats.

Some example code to get you started

Consider the code shown below, which showcases the use of sort algorithm available in STL.

#include  #include  #include  // time() #include  // srand(), rand() #include  // min_element(), max_element(), sort() bool sort(int i, int j) { return (i x; int n = 10; for (int i=0; ifor (std::vector::iterator xi = x.begin(); xi != x.end(); xi++) { std::cout << *xi << std::endl; } std::cout << "min value = " << *std::min_element(x.begin(), x.end()) << std::endl; std::cout << "index of min value = " << std::min_element(x.begin(), x.end()) - x.begin() << std::endl; std::cout << "max value = " << *std::max_element(x.begin(), x.end()) << std::endl; std::cout << "index of max value = " << std::max_element(x.begin(), x.end()) - x.begin() << std::endl; std::sort(x.begin(), x.end()); for (std::vector::iterator xi = x.begin(); xi != x.end(); xi++) { std::cout << *xi << std::endl; } std::sort(x.begin(), x.end(), sort); for (std::vector::iterator xi = x.begin(); xi != x.end(); xi++) { std::cout << *xi << std::endl; } return 0; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

50 Tips And Tricks For MongoDB Developers Get The Most Out Of Your Database

Authors: Kristina Chodorow

1st Edition

1449304613, 978-1449304614

More Books

Students also viewed these Databases questions

Question

What are the health and safety conditions?

Answered: 1 week ago

Question

Presenter view requires only one monitor through or false

Answered: 1 week ago