Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Integrity Statement: Read carefully! Strict directives have been given to the as

ID: 3680860 • Letter: I

Question

Integrity Statement:   Read carefully!

Strict directives have been given to the assistants who will be marking this homework as a departmental policy is being developed on cheating. Any student caught in any form of cheating will be given zero (0) the first time. (We will not get into the issue of who copied from whom!!!). If such an act reoccurs, the case will be sent to the Student Discipline Committee.

Submit this cover page with your assignment and sign here that you have read and understood this "Integrity Statement" paragraph.




A student has a name and he/she is in a year of study (level). Each year the student takes a number of courses and score marks for those courses and ends with a GPA for that year. The CGPA for courses of all years is calculated too. The weight of a mark between 0 and 60 is 0, the weight of a mark between 60 and 70 is 1, the weight of a mark between 70 and 80 is 2, the weight of a mark between 80 and 90 is 3, and the weight of a mark between 90 and 100 is 4. Assuming that w stands for the weight of the mark and c stands for the course credit’s then the GPA is calculated using the following formula:

Define a struct called Year with components numberOfCourses, an array marks[ ], an array credits[ ] of type int, and GPA of type float.

Define a class called Student with private data members name of type string, level of type int, CGPA of type float, an array studyYear[ ] of type Year. The class also has the private member functions calculateGPA(int), and calculateCGPA(). The class has the public member functions set(int), getGPA(int), getCGPA(), print(), a default constructor, and constructor with parameters.

Note: Inforce the least privileged principle by using const to prevent member functions from changing the data members.

Use the following driver:

int main()

{

    Student someone;

    int whichYear;

    cout << "Enter which year: ";

    cin >> whichYear;

    cin.ignore();

    someone.set(whichYear);

    someone.print();

    return 0;

}

Sample input / output:

Explanation / Answer

#ifndef STUDENT_H
#define STUDENT_H

#include <string>
using namespace std;

class Student
{
    private:
        int Year;
        string name;
        double GPA;
        double CGPA;
        char gender;
    public:
        Student();
        Student(int Year, string name, double GPA, char gender);
        voYear setStudent(int Year, string name, double GPA, char gender);
        int getYear();
        string getName();
        double getGPA();
        double getCGPA();
        char getGender();
        voYear print();
};
#endif


#include "Student.h"
#include <iostream>
using namespace std;

Student :: Student()
{
    Year = 0;
    name = "";
    GPA = 0;
    CGPA = 0;
    gender = ' ';
}
Student :: Student(int Year, string name, double GPA,double CGPA, char gender)
{
    this -> Year = Year;
    this -> name = name;
    this -> GPA = GPA;
    this -> CGPA = CGPA;
    this -> gender = gender;
}

voYear Student :: setStudent(int Year, string name, double GPA,double GPA, char gender)
{
    this -> Year = Year;
    this -> name = name;
    this -> GPA = GPA;
    this -> CGPA = CGPA;
    this -> gender = gender;
}

int Student :: getYear()
{
    return Year;
}

string Student :: getName()
{
    return name;
}

double Student :: getGPA()
{
    return GPA;
}

double Student :: getCGPA()
{
    return CGPA;
}

char Student :: getGender()
{
    return gender;
}

voYear Student :: print()
{
    cout << "Year : " << Year << endl;
    cout << "Name : " << name << endl;
    cout << "GPA : " << GPA << endl;
    cout << "CGPA : " << CGPA << endl;
    cout << "Gender : " << gender << endl;
}

Main

#include <iostream>
#include "Student.h"
using namespace std;

int main()
{
    Student s;

    cout << "Enter Year ";
    cin >> s.Year;

    cout << "Enter name ";
    cin >> s.name;

    cout << "Enter GPA ";
    cin >> s.GPA;

    cout << "Enter CGPA ";
    cin >> s.CGPA;
  
    cout << "Enter gender ";
    cin >> s.gender;

    s.print();
    return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote