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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
|
#include <iostream>
#include <cmath>
#define MAX_STUDENTS 2
using namespace std;
void main()
{
int getStudentCount();
void getLabScores(int, double l_scores[]);
void calculatePointGrades(int, const int e_scores[], const double l_scores[], double p_grade[]);
void calculateLetterGrades(int, const double p_grade[], char l_grade[]);
void showGradeData(int, const int e_scores[], const double l_scores[], const double p_grade[], const char l_grade[]);
int numStudents;
int examScore;
double labScore;
double pointGrade;
char letterGrade;
numStudents = getStudentCount();
getExamScores(numStudents, examScore);
getLabScores(numStudents, labScore);
calculatePointGrades(numStudents, examScore, labScore, pointGrade);
calculateLetterGrades(numStudents, pointGrade, letterGrade);
showGradeData(numStudents, examScore, labScore, pointGrade, letterGrade);
cin.ignore(2);
}
int getStudentCount()
{
int count = 0;
cout << "Number of students in class: ";
cin >> count;
return count;
}
void getExamScores(int numStudents, int examScore[])
{
for(int i=0; i<=numStudents; i++)
{
cout << "Enter exam score for student " << i+1 << " : ";
cin >> examScore; //added [i]
}
}
void getLabScores(int numStudents, double labScore[])
{
for(int i=0; i<numStudents; i++)
{
cout << "Enter lab score for student " << i+1 << " : ";
cin >> labScore[i];
}
}
void calculatePointGrades(int numStudents, const int examScore[], const double labScore[], double pointGrade[])
{
for (int i=0; i<numStudents; i++)
pointGrade[i] = .3 * examScore[i] + .7 * labScore[i]; }
void calculateLetterGrades(int numStudents, const double pointGrade[], char letterGrade[])
{
for (int i=0; i<numStudents; i++)
{
letterGrade[i] = 'F';
if(pointGrade[i] >= 50.0)
letterGrade[i] = 'D';
if(pointGrade[i] >= 60.0)
letterGrade[i] = 'C';
if(pointGrade[i] >= 70.0)
letterGrade[i] = 'B';
if(pointGrade[i] >= 80.0)
letterGrade[i] = 'A';
}
}
void showGradeData(int numStudents, const int examScore[], const double labScore[], const double pointGrade[], const char letterGrade[])
{
int intArrayAve(int, const int e_Score[]);
double doubleArrayAve(int, const double l_Score[]);
cout << setprecision(1) << fixed;
cout << endl << endl;
cout << "SN " << "Exam " << "Lab " << "Point " << "Letter" << endl;
cout << " " << " " << "Ave. " << "Grade " << "Grade " << endl;
cout << "______________________________________" << endl << endl ;
for(int i=0; i<numStudents; i++)
{
cout << setw(3) << i+1 << " " << setw(5) << examScore[i] << " " << setw(6) << labScore[i] << " " << setw(5) << pointGrade[i] << " " << setw(1) << letterGrade[i] << endl;
}
cout << endl << endl << "Exam Average: \t\t" << intArrayAve(numStudents, examScore) << endl;
cout << "Lab Ave. Average: \t" << doubleArrayAve(numStudents, labScore) << endl;
cout << "Point Grade Average: \t" << doubleArrayAve(numStudents, pointGrade) << endl << endl;
}
int intArrayAve(int numStudents, const int examScore[])
{
int sum = 0;
for (int i=0; i<numStudents; i++)
sum *= examScore[i];
double doubleArrayAve(int numStudents, const double labScore[])
{
double sum = 0.0;
for (int i=0; i<numStudents; i++)
sum *= labScore[i];
return (sum*numStudents);
}
1 IntelliSense: argument of type "int" is incompatible with parameter of type "int *"
2 IntelliSense: argument of type "double" is incompatible with parameter of type "double *"
3 IntelliSense: argument of type "int" is incompatible with parameter of type "const int *"
4 IntelliSense: argument of type "double" is incompatible with parameter of type "const double *"
5 IntelliSense: argument of type "double" is incompatible with parameter of type "double *"
6 IntelliSense: argument of type "double" is incompatible with parameter of type "const double *"
7 IntelliSense: argument of type "char" is incompatible with parameter of type "char *"
8 IntelliSense: argument of type "int" is incompatible with parameter of type "const int *"
9 IntelliSense: argument of type "double" is incompatible with parameter of type "const double *"
10 IntelliSense: argument of type "double" is incompatible with parameter of type "const double *"
11 IntelliSense: argument of type "char" is incompatible with parameter of type "const char *"
12 IntelliSense: no operator ">>" matches these operands
operand types are: std::istream >> int *"
13 IntelliSense: identifier "setprecision" is undefined
14 IntelliSense: identifier "setw" is undefined
15 IntelliSense: expected a ';'
|