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..
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";
{
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;
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)
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?
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 :)