Help
I can't figure out why I can't compile this program. Any help?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
int main()
{
const int MAX_QUIZ = 15;
double points_possible,
points_earned,
points_possible_array[MAX_QUIZ],
points_earned_array[MAX_QUIZ],
sum_points_possible = 0,
sum_points_earned = 0,
dropped_quiz_avg;
int quiz_to_drop,
highest_quiz_num = 0,
quiz_number;
ifstream in_file;
in_file.open("quizinfo.txt");
if (!in_file)
{
cout << "Input failed to open." << endl;
return 1;
}
cout << "Please enter the data asked below in the input file. "
"The end of the data is indicated by a negative quiz"
" number and 0s for the other"
" two data values on the line." << endl;
cout << "Quiz number" << setw(10) << "Maximum points on the quiz"
<< setw(10) << "Points earned" << endl;
in_file >> quiz_number >> points_possible >> points_earned;
cout << "Please enter the quiz number you want to drop."
<< quiz_to_drop;
while (quiz_number >= 0 && points_possible != 0 && points_earned!=0)
{
points_possible[quiz_number] = points_possible;
highest_quiz_num = quiz_number;
in_file >> quiz_number >> points_possible >> points_earned;
}
for (int i = 0; i <= highest_quiz_num; i++)
{
sum_points_earned += points_earned_array[i];
}
for (int i; i <= highest_quiz_num; i++)
{
sum_points_possible += points_possible_array[i];
}
dropped_quiz_avg= 100* ( (points_earned - sum_points_possible)
/(points_possible - sum_points_earned));
cout << "Quiz number" << setw(5) << "Maximum points on the quiz"
<< setw(5) << "Points earned" << endl;
for(int i = 0; i <= highest_quiz_num; i++)
{
cout << i << points_possible_array[i] << points_earned_array[i];
}
cout << "The average grade is " << setprecision(0) << fixed
<< dropped_quiz_avg << endl;
return 0;
}
|
Why do you ignore compiler errors? Please read error messages that the compiler issue.
All it said was that you cant have a double and an int in line 48. I don't understand how arrays work so I do not know how to fix it.
i think you meant points_possible_array[quiz_number] = points_possible
yes. that is exactly my problem and i do not know how to fix it. and I would really like some help.
I think what DTSCode means is that at line 48,
|
points_possible[quiz_number] = points_possible;
|
the variable points_possible[quiz_number] should really be points_possible_array[quiz_number]
Topic archived. No new replies allowed.