* Machine Problem in C++

*

* Student Class Record

* Start by asking the users for a list of students (three or more).

* The user has 2 options after,view grades and input quiz scores.

* On view grades, show the average grade of each

* student (total score/total quiz).

* On input quiz scores, first ask for the total quiz items.

* Then ask for the score of each student (you initialized). Done.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details. If you want to advertise on my website kindly contact me also in my email address also. Thank you. My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com. My mobile number here in the Philippines is 09173084360.

Program Listing

```
/*
* grades.cpp
* Mr. Jake Rodriguez Pomperada, MAED-IT, MIT
* www.jakerpomperada.com and www.jakerpomperada.blogspot.com
* jakepomperada@gmail.com
* Bacolod City, Negros Occidental Philippines
* December 18, 2021 Saturday
*
* Machine Problem in C++
*
* Student Class Record
* Start by asking the users for a list of students (three or more).
* The user has 2 options after,view grades and input quiz scores.
* On view grades, show the average grade of each
* student (total score/total quiz).
* On input quiz scores, first ask for the total quiz items.
* Then ask for the score of each student (you initialized). Done.
*/
#include <iostream>
#include <vector>
#include <numeric>
class Student
{
public:
void add_score(int score)
{
m_scores.push_back(score);
}
double get_avg_score() const noexcept
{
double sum = std::accumulate(m_scores.begin(), m_scores.end(), 0.0);
return sum / m_scores.size();
}
private:
std::vector<int> m_scores;
};
std::vector<Student> enter_scores(int num_students)
{
int num_scores = 0, temp = 0;
std::cout << "How many scores per student: ";
std::cin >> num_scores;
std::vector<Student> students;
for (int j = 0; j < num_students; ++j)
{
Student student;
for (int i = 0; i < num_scores; ++i)
{
std::cout << "Score " << i + 1 << " for student " << j + 1 << ": ";
std::cin >> temp;
student.add_score(temp);
}
students.push_back(student);
}
return students;
}
void view_scores(const std::vector<Student>& students)
{
std::cout << "\n\n";
std::cout << "Students report\n";
std::cout << "===============\n\n";
int count = 1;
if (students.empty())
{
std::cout << "No students to report.\n";
return;
}
for (const auto& student : students)
{
std::cout << "Average score for student " << count++ << '\t'
<< student.get_avg_score() << "\n";
}
}
int main()
{
int num_students = 0, choice = 0;
bool finished = false;
std::vector<Student> students;
std::cout << "\n";
std::cout << "\tStudent Class Record in C++\n";
std::cout << "\n";
std::cout << "Number of students(min 3): ";
std::cin >> num_students;
if (num_students < 3)
{
std::cout << "Invalid number of students.\n";
finished = true;
}
while (!finished)
{
std::cout << "1 - Enter scores\n2 - View scores\n3 - Exit\n";
std::cout << "Enter your choice: ";
std::cin >> choice;
if (choice == 1)
students = enter_scores(num_students);
else if (choice == 2)
view_scores(students);
else if (choice == 3)
finished = true;
}
}
```