so basically, i think i have the basic idea written down but am not really understanding the errors i recieve like for example one of the errors were, "error: invalid conversion from `int' to `double*'" but ya...code if below....id appriciate the help, thanks
/**
* CS-11 Asn 9
* gradebook.cpp
* Purpose: calculates overall grade for the semester.
*
* @author Ramin Rezaei
* @version 1.0 4/27/06
*/
#include <fstream>
#include <iostream>
using namespace std;
// Avoid magic numbers.
// Change the following constants however you like.
const int NUM_AREAS = 4;
const int MAX_ASN = 11;
const int MAX_EXER = 12;
const int MAX_MID = 2;
const int MAX_FINAL = 2;
const double WEIGHT_ASN = .30;
const double WEIGHT_EXER = .15;
const double WEIGHT_MID = .20;
const double WEIGHT_FINAL = .35;
const double WEIGHTS[] = {WEIGHT_ASN, WEIGHT_EXER, WEIGHT_MID, WEIGHT_FINAL};
const string AREAS[] = {"Assignments", "Exercises", "Midterm", "Final Exam"};
const int INDEX_ASN = 0;
const int INDEX_EXER = 1;
const int INDEX_MID = 2;
const int INDEX_FINAL = 3;
const double MIN_A = .90;
const double MIN_B = .80;
const double MIN_C = .70;
const double MIN_D = .60;
const int NUM_DECIMAL_PLACES = 2;
const double PERCENT_MULTIPLIER = 100;
/**
* Load the scores from the fileName into data[].
*
* @param fileName The name of the file.
* @param data The array in which the data is loaded.
* @param size The maximum array size.
* @return The number of elements loaded into the array.
*/
int loadScores(double data[], int size, string fileName);
/**
* Calculates the weighted percentage of the data where data[0] is
* the maximum possible for all scores and each subsequent item is
* an individual score. Also makes sure that the score does not
* exceed 100%.
*
* @param data The array in which the data is loaded.
* @param size The number of array items used.
* @param weight The weight to apply to the data percentage.
* @return The weighted percentage.
*/
double calcScore(double data[], int numItems, double weight);
/**
* Outputs the grade calculations in the specified format.
*
* @param weightedScores The weighted percentages of all areas.
* @param size The number of array elements.
* @param out The output stream to write the data to.
*/
void report(double weightedScores[], int size, ostream& out);
/**
* Converts the percentage to a letter grade.
*
* @param percentage The percentage to convert.
* @return The letter grade.
*/
double calcScoreNeeded(double wanted, double earned);
// Application driver
int main() {
ifstream fin;
ofstream fout;
string filenName;
double numItems;
int asn[MAX_ASN];
int exer[MAX_EXER];
int mid[MAX_MID];
int final[MAX_FINAL];
//fileName = "asn.txt";
loadScores(asn[MAX_ASN],"asn.txt");
calcScore(asn[MAX_ASN],numItems, WEIGHT_ASN);
//fileName = "exer.txt";
loadScores(exer[MAX_EXER],"exer.txt");
calcScore(exer[MAX_EXER],numItems, WEIGHT_EXER);
//fileName = "mid.txt";
loadScores(mid[MAX_MID],"mid.txt");
calcScore(mid[MAX_MID],numItems, WEIGHT_MID);
//fileName = "final.txt";
loadScores(final[MAX_FINAL],"final.txt");
calcScore(final[MAX_FINAL],numItems, WEIGHT_FINAL);
return 0;
}
// Load the scores from the fileName into data[].
int loadScores(double data[], int size, string fileName) {
size=size;
ifstream fin;
ofstream fout;
int count = 0;
fin.open(filename);
if (fin.fail()) {
cout << "Input file failed to open.\n";
exit(1);
}
while(fin >> data[count] && count < size) {
count++;
}
// Read the number of scores
// Also load scores into the data[]
return count;
}
// Calculates the weighted percentage of the data where data[0] is the maximum
// possible for all scores and each subsequent item is an individual score.
// Also makes sure that the score does not exceed 100%.
double calcScore(double data[], int numItems, double weight) {
double result = 0;
double numItems;
for (int i = 0; i < numItems; i++) {
result = result + data [i]
}
result = result / data [0];
result*weight;
if (data[0] > 1 ) {
result=1;
}
if (data[i] ==0) {
result=0;
}
// DANGER: watch out for division by zero!!!!
return result;
}
// Outputs the grade calculations in the specified format.
void report(double weightedScores[], int size, ostream& out) {
}
// Converts the percentage to a letter grade.
char toLetterGrade(double percentage) {
char letterGrade = 'z';
// Use if-else statements to return a letter grade
return letterGrade;
}