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
|
#include <iostream>
using namespace std;
// Class student
class student
{
public:
int ma8ima_1; // <--- All 3 should be a "double". Also should be "private".
int ma8ima_2;
int ma8ima_3;
student(); // <--- Needed. No longer provided by the compiler because of the next line.
student(double a, double b, double c);
//~student(); // <--- Not necessary unless you define your own. Which is not necessary here. Will be provided by the compiler.
double mesos_oros(double a, double b, double c); // <--- Changed name.
}; // <--- stnt[10]; This array never used.
// Dummy constructor. Default ctor not dummy.
student::student()
{
ma8ima_1 = 0;
ma8ima_2 = 0;
ma8ima_3 = 0;
}
//constructor. Overloaded ctor.
student::student(double a, double b, double c)
{
ma8ima_1 = a; // <--- These lines storing a "double" in an "int". Will loose the decimal part.
ma8ima_2 = b;
ma8ima_3 = c;
}
// destructor. Will be provided by the compiler.
//student::~student()
//{
//
//}
// average method
double student::mesos_oros(double a, double b, double c) // <--- Changed name.
{
return (a + b + c) / 3;
}
int main()
{
//variable and object array definitions
int i, a, b, c, count1 = 0, count2 = 0;
student stnt[10];
//Inputs the grades for the first course
cout << "dwse ba8mous sto prwto ma8ima" << endl; // <--- give grades in the first lesson.
for (i = 0; i < 10; i++)
{
cin >> a;
stnt[i].ma8ima_1 = a;
}
//Inputs the grades for the second course
cout << "dwse ba8mous sto deutero ma8ima" << endl; // <--- give grades in the second lesson.
for (i = 0; i < 10; i++)
{
cin >> b;
stnt[i].ma8ima_2 = b;
}
//Inputs the grades for the third course
cout << "dwse ba8mous sto trito ma8ima" << endl; // <--- give grades in the third lesson.
for (i = 0; i < 10; i++)
{
cin >> c;
stnt[i].ma8ima_3 = c;
}
//prints the array of students with student's 3 courses
for (i = 0; i < 10; i++)
{
cout << stnt[i].ma8ima_1 << endl;
cout << stnt[i].ma8ima_2 << endl;
cout << stnt[i].ma8ima_3 << endl;
}
//Finds the average for each student
for (i = 0; i < 10; i++)
{
if (stnt[i].mesos_oros(a, b, c) < 9.5)
{
cout << "apetuxe" << endl;
count1++;
}
else if (stnt[i].mesos_oros(a, b, c) > 18.5)
{
cout << "petuxe" << endl;
count2++;
}
}
//prints how excelled and who failed
cout << "apetuxan: " << count1 << " " << "foitites" << "se pososto " << " " << (count1) / (count1 + count2) << '%' << endl;
cout << "petuxan: " << count2 << " " << "foitites" << "se pososto " << " " << (count2) / (count1 + count2) << '%' << endl;
return 0;
}
|