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

What is the correct way to use \"Modules\" in c++?

ID: 3551339 • Letter: W

Question


I am working on this program and I am not sure what I am doing wrong.
---------------------------------------...
student.h
---------------------------------------...
#ifndef STUDENT_H_INCLUDED
#define STUDENT_H_INCLUDED
#include <fstream>

#include <string>
using namespace std;

void addGrade(std::string name, int credits, double qp);
double computeGPA (std::string const Student& aStudent);

#endif
---------------------------------------...
student.cpp
---------------------------------------...
#include "student.h"

using namespace std;
Student::Student
{
}
struct Student () {
string name;
int credits;
double qp;
};

void addGrade(Student& aStudent, string grade, int credits)
{
aStudent.credits += credits;
double v = findGradeValue(gradeValues, 11, grade);
aStudent.qp += credits * v;
}

double Student::computeGPA (const Student& aStudent)
{
if (aStudent.credits > 0)
return aStudent.qp / aStudent.credits;
else
return 0.0;
}
---------------------------------------...
I am working on this program and I am not sure what I am doing wrong.
---------------------------------------...
student.h
---------------------------------------...
#ifndef STUDENT_H_INCLUDED
#define STUDENT_H_INCLUDED
#include <fstream>

#include <string>
using namespace std;

void addGrade(std::string name, int credits, double qp);
double computeGPA (std::string const Student& aStudent);

#endif
---------------------------------------...
student.cpp
---------------------------------------...
#include "student.h"

using namespace std;
Student::Student
{
}
struct Student () {
string name;
int credits;
double qp;
};

void addGrade(Student& aStudent, string grade, int credits)
{
aStudent.credits += credits;
double v = findGradeValue(gradeValues, 11, grade);
aStudent.qp += credits * v;
}

double Student::computeGPA (const Student& aStudent)
{
if (aStudent.credits > 0)
return aStudent.qp / aStudent.credits;
else
return 0.0;
}
---------------------------------------...

Explanation / Answer

#include "student.h"
using namespace std;
using namespace Student;

void addGrade(Student::Student aStudent, string grade, int credits)
{
    aStudent.credits += credits;
    double v = findGradeValue(gradeValues, 11, grade);
    aStudent.qp += credits * v;
}

double Student::computeGPA (const Student& aStudent)
{
    if (aStudent.credits > 0)
        return aStudent.qp / aStudent.credits;
    else
        return 0.0;
}




#ifndef STUDENT_H_INCLUDED
#define STUDENT_H_INCLUDED
#include <fstream>

#include <string>
using namespace std;
namespace Student
{
struct Student {
    string name;
    int credits;
    double qp;
};
void addGrade(Student aStudent, std::string grade, int credits);
double computeGPA (const Student* aStudent);
}
#endif




the format must be this change them accordingly

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