+1 (315) 557-6473 

C++ Programming in Visual Studio Homework Help

Get professional C++ programming in visual studio homework help right here at Programming Homework help. We boast of highly qualified and immensely experienced coders who specialize in C++ and Visual Studio. They write codes that do not return errors and are well commented. Take C++ programming in visual studio homework help and earn your dream grade. You will also get to enjoy a myriad of benefits including prompt deliveries, affordable rates and discounts and many more.

Creating a Grade Management Program in Visual Studio

Your task is to create a grade management program for student grades. Your program should contain the classes Student and Subject (see class diagrams):
C++ in visual studio

Data Elements and Element Functions Special Features

• The constructor of Subject should be able to initialize the data elements description and grade with externally adopted values on the one hand, but on the other hand it should also be a standard constructor that creates a not yet named and graded subject (the description of the subject has the Value ““ (empty string) and the grade of the subject just the value 0.0).
• toString should return the data of a Subject object in a suitable formatting as a string (see sample output on the next page).
• Student's standard constructor is to create a student whose matNr has the value 0. The subjects (i.e. the subject objects in the subjects array) do not yet contain grades, but they already contain the correct names: The names to be set by the constructor are PAD1, PAD2, TGI, EDM, WI, ITS and MIC.
• takeExams ('carry out exams') should assign a grade to all objects in subjects. Each individual note should be randomly selected from the set of 11 possible note values 1.0, 1.3, 1.7, 2.0, 2.3, 2.7, 3.0, 3.3, 3.7, 4.0 and 5.0 with the same probability.
o If there is at least a 5.0 among the assigned grades, true should be returned, if not, false should be returned.
• repeatExams ('Carry out repeat exams') should assign a new grade to all objects in subjects that contain a grade of 5.0 (and only these!). This new grade should again be chosen at random from the possible grade values (see above) with the same probability.
o If there is at least a 5.0 among the assigned grades, true should be returned, if not, false should be returned.
• sortByGrade is to sort the Subject objects within the subjects array according to increasing grade value. The sorting method 'direct selection (selection sort)' should be used here.
• sortByDescription is to sort the Subject objects within the subjects array alphabetically according to the description. You can use a sorting method of your choice (except for 'Selection-Sort', see above).
• averageGrade is to calculate and return the average value of all grades stored in a student object.
• toString should return the matriculation number, the subjects contained in the student object with the associated grades and the average value of the grades in the following formatting as a string:

C++ in visual studio

Testing the Two Classes

The application program (main) should test the two classes. To do this, the following actions should take place in the sequence (menu control should therefore not be implemented):
• Creation of an array with 30 student objects.
• Homework of a unique four-digit matriculation number to each of the 30 student objects, execution of the exams, and output of all results in the format as specified above (initially no sorting is necessary). In addition, the average value of the 30 average values belonging to the individual students should be calculated and output.
• Sorting according to grade values and output of all results in the format specified above.
• Sorting according to descriptions and output of all results in the format as specified above.
• Afterwards: Carrying out the exams including repeat exams for 30 new students in the
following way: Assigning a new unique four-digit matriculation number to each of the 30 student objects, carrying out the exams and carrying out a maximum of two repeat exams for those subjects which were completed with 5.0, then sorting by grades and output of all results in the format as stated above. In addition, the average value of the 30 average values belonging to the individual students should also be calculated and output here.

C++ Code Solution

// Students.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include
#include
#include
#include
#define SUBJECT_NUM 7
using namespace std;
class Subject {
private:
 string description;
 double grade;
public:
 const static int possibleGradesNum = 11;
 const static double possibleGrades[];
 Subject(string _description = "", double _grade = 0.0) {
  description = _description;
  grade = _grade;
 }
 string toString() {
  stringstream stream;
  stream << fixed << setprecision(1) << grade;
  return description + ":" + stream.str();
 }
 double getGrade() {
  return grade;
 }
 string getDescription() {
  return description;
 }
 void setGrade(double _grade) {
  grade = _grade;
 }
};
const double Subject::possibleGrades[] = { 1.0, 1.3, 1.7, 2.0, 2.3, 2.7, 3.0, 3.3, 3.7, 4.0, 5.0 };
class Student {
private:
 int matNr;
 Subject subjects[SUBJECT_NUM];
public:
 Student() {
  matNr = 0;
  subjects[0] = Subject("PAD1");
  subjects[1] = Subject("PAD2");
  subjects[2] = Subject("TGI");
  subjects[3] = Subject("EDM");
  subjects[4] = Subject("WI");
  subjects[5] = Subject("ITS");
  subjects[6] = Subject("MIC");
 }
 void setMatNr(int _matNr) {
  matNr = _matNr;
 }
 bool takeExams() {
  bool hasMax = false;
  for (int i = 0; i < SUBJECT_NUM; i++) {
   int index = rand() % Subject::possibleGradesNum;
   if (index == Subject::possibleGradesNum - 1) {
    hasMax |= true;
   }
   subjects[i].setGrade(Subject::possibleGrades[index]);
  }
  return hasMax;
 }
 bool repeatExams() {
  bool hasMax = false;
  for (int i = 0; i < SUBJECT_NUM; i++) {
   if (subjects[i].getGrade() < Subject::possibleGrades[Subject::possibleGradesNum - 1]) {
    continue;
   }
   int index = rand() % Subject::possibleGradesNum;
   if (index == Subject::possibleGradesNum - 1) {
    hasMax |= true;
   }
   subjects[i].setGrade(Subject::possibleGrades[index]);
  }
  return hasMax;
 }
 void sortByGrade() {
  for (int i = 0; i < SUBJECT_NUM-1; i++) {
   int index = -1;
   double lowGrade = 10.0;
   for (int j = i; j < SUBJECT_NUM; j++) {
    if (subjects[i].getGrade() < lowGrade) {
     lowGrade = subjects[i].getGrade();
     index = i;
    }
   }
   if (index != i) {
    Subject sw = subjects[i];
    subjects[i] = subjects[index];
    subjects[index] = sw;
   }
  }
 }
 void sortByDescription() {
  for (int i = 0; i < SUBJECT_NUM - 1; i++) {
   for (int j = 0; j < SUBJECT_NUM - 1 - i; j++) {
    if (subjects[j].getDescription().compare(subjects[j + 1].getDescription()) > 0) {
     Subject sw = subjects[j+1];
     subjects[j+1] = subjects[j];
     subjects[j] = sw;
    }
   }
  }
 }
 double averageGrade() {
  double sum = 0;
  for (int i = 0; i < SUBJECT_NUM; i++) {
   sum += subjects[i].getGrade();
  }
  return sum / SUBJECT_NUM;
 }
 string toString() {
  string result = to_string(matNr) + ": ";
  for (int i = 0; i < SUBJECT_NUM; i++) {
   result += " " + subjects[i].toString();
  }
  stringstream stream;
  stream << fixed << setprecision(2) << averageGrade();
  result += " Avg=" + stream.str();
  return result;
 }
};
int main()
{
 const int n = 30;
 Student students[n];
 for (int i = 0; i < n; i++) {
  students[i] = Student();
  students[i].setMatNr(7000 + i);
 }
 for (int i = 0; i < n; i++) {
  students[i].sortByGrade();
  cout << students[i].toString() << endl;
 }
 cout << endl;
 for (int i = 0; i < n; i++) {
  students[i].sortByDescription();
  cout << students[i].toString() << endl;
 }
 cout << endl;
 for (int i = 0; i < n; i++) {
  students[i].setMatNr(8000 + i);
  if (!students[i].takeExams()) {
   for (int j = 0; j < 2; j++) {
    if (!students[i].repeatExams()) {
     break;
    }
   }
  }
  students[i].sortByDescription();
  cout << students[i].toString() << endl;
 }
}
// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu
// Tips for Getting Started:
// 1. Use the Solution Explorer window to add/manage files
// 2. Use the Team Explorer window to connect to source control
// 3. Use the Output window to see build output and other messages
// 4. Use the Error List window to view errors
// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file
Related Blogs