Having problems with gradeCalculator

im trying to make a gradeCalculator that takes in inputs through a function, multiplies the grades by a constant value for their weighted % and calculate the final grade and output it using a funciton

here is what I have so far, I am new to this so there is probably a lot wrong..

#include <iostream>
#include <iomanip>

using namespace std;

void displayOverview();
void getInput(int onlineEarn, double onlinePoss, int inclassEarn,
double inclassPoss, int programEarn, double programPoss,
int dailyEarn, double dailyPoss);
void getInput1(int& onlineEarn2, double& onlinePoss2, int& inclassEarn2,
double& inclassPoss2, int& programEarn2, double& programPoss2,
int& dailyEarn2, double& dailyPoss2);
void calcRatios1(double dailyEarn, double dailyPoss, double programEarn,
double programPoss, double& programRatio, double&
dailyRatio);
void calcRatios2(double onlineEarn,double onlinePoss, double inclassEarn,
double inclassPoss, double& onlineRatio, double&
inclassRatio);
double calcCurrentPercent(double onlineRatio, double inclassRatio, double
programRatio, double dailyRatio);
void outputGradeCalculator(
int main()
{
double onlinePoss,
inclassPoss,
programPoss,
dailyPoss;

int onlineEarn,
inclassEarn,
programEarn,
dailyEarn;

const double DAILY_WT = .15;
const double ONLINE_WT = .1;
const double INCLASS_WT = .3;
const double PROGRAM_WT = .15;

//function calls

displayOverview();
getInput(onlineEarn, onlinePoss, inclassEarn, inclassPoss,
programEarn, programPoss, dailyEarn, dailyPoss);
calcRatios1(programEarn, programPoss, dailyEarn, dailyPoss,
programRatio, dailyRatio);
calcRatios2(onlineEarn, onlinePoss, inclassEarn, inclassPoss,
onlineRatio, inclassRatio);
currentPercent = calcCurrentPercent(programRatio, dailyRatio,
onlineRatio, inclassRatio);
cin.ignore();
cout << "\n\n Press Enter to close the program.";
cin.get();

return 0;
}
void displayOverview()
{
cout << "This program takes in your points and points possible for "
<< "daily points, program points, online points, in class quizes "
<< "and divides them out and multiplies them by 100 to get your "
<< "total grade without your final test calculated in."
<< "\n\n";

return;

} //Display overview
void getInput(int& onlineEarn2, double& onlinePoss2, int& inclassEarn2,
double& inclassPoss2, int& programEarn2, double& programPoss2,
int& dailyEarn2, double& dailyPoss2)

{
cout << "\n Enter the online d2l quiz points earned: ";
cin >> onlineEarn2;
cout << "\n Enter the online d2l quiz points possible: ";
cin >> onlinePoss2;
cout << "\n Enter the in class point earned: ";
cin >> inclassEarn2;
cout << "\n Enter the in class points possible: ";
cin >> inclassPoss2;
cout << "\n Enter the program points earned: ";
cin >> programEarn2;
cout << "\n Enter the program points possible: ";
cin >> programPoss2;
cout << "\n Enter the daily points earned: ";
cin >> dailyEarn2;
cout << "\n Enter the daily points possible: ";
cin >> dailyPoss2;

return;
}
This has been creaping up a lot recently. You haven't completely understood how to use functions. I imagine you are getting results of 0 everytime?

Basically, if you were going to use functions in this way, you need each function to pass-by-reference, not pass-by-value e.g.:

1
2
3
void getInput(int &onlineEarn, double &onlinePoss, int &inclassEarn,
double &inclassPoss, int &programEarn, double &programPoss, 
int &dailyEarn, double &dailyPoss);


This way when your function processes them variables in whatever way it does, it changes the values in main(), not just the copies in the function.

But you shouldn't use functions in this way. Read up on a tutorial again and try and figure out a better way to use them. (a method that doesn't involve passing those values to every function)
Last edited on
The only errors I am getting is that it's saying 'programRatio' is undeclared and so on for the others in the function void getInput(int &onlineEarn, double &onlinePoss, int &inclassEarn,
double &inclassPoss, int &programEarn, double &programPoss,
int &dailyEarn, double &dailyPoss);
and also that currentPercent is undeclared.

Could this be happening because I have not written the output function part of the program?
My post wasn't saying that they were errors, its was stating what will happen when you can compile your program.

With regards to those errors, it means that you have not declared them anywhere. For example, you have the line:

1
2
currentPercent = calcCurrentPercent(programRatio, dailyRatio,
onlineRatio, inclassRatio);


But nowhere in your code do you actually create the variable 'currentPercent'.
I am very new to this, do I put that above int main() or where would that go?

Thank you kindly
The only errors I am getting is that it's saying 'programRatio' is undeclared and so on for the others in the function void getInput(int &onlineEarn, double &onlinePoss, int &inclassEarn,
double &inclassPoss, int &programEarn, double &programPoss,
int &dailyEarn, double &dailyPoss);
and also that currentPercent is undeclared.

Could this be happening because I have not written the output function part of the program?


I agree to mcleano. You should declare this "currentPercent" before calling it. :)

You can search to google for some tutorials about creating functions :)

Regards,
nemesis
Topic archived. No new replies allowed.