Hey,
The objective of REPORT function is to output a specific response to another file based on the input. I am stuck when there is a student existing and the input is z=-1. Then the output should display all of the students grade from each project. The file which the students are listed is the following, where the first column is id, then pin, and then grades for each project. I appreciate the community's help.
void
P2_GRADES::P2_REPORT(int x, int y, int z)
{
int i, FOUND, FOUND_POS, j;
output_file << "P2 START =====================================" << endl;
output_file << "P2 OUTPUT FROM P2_REPORT INTERFACE:" << endl;
if(x==-1 && y==-1 && z==-1)
{
P1_LIST();
}
elseif (x>=0 && x<=9999)
{
FOUND=0;
for(i=0;i<n && FOUND==0; i++)
{
if(id[i]==x && pin[i]==y)
{
FOUND=1; FOUND_POS=i;
//if (FOUND==1)
//{
//output_file<<"P2 THE GRADE OF STUDENT "<<id[i]<<" FOR PROJECT 1 IS "<<projects[i][1]<<endl;
//}
}
else{}
}
if (FOUND==1)
{
output_file<<"P2 THE GRADE OF STUDENT "<<id[i-1]<<" FOR PROJECT 1 IS "<<projects[i-1][1]<<endl;
if(FOUND==1 && z==-1)
{
for(i=0;i<n;i++)
{
output_file<<"P2 THE GRADE OF STUDENT "<< x<< " FOR PROJECT "<<i<<" IS "<<projects[x][i]<< "."<<endl;
}
}
elseif(FOUND==0)
{
output_file<<"P2 NO SUCH STUDENT WITH ID "<<x<<"."<<endl;
}
this is the main
1 2 3 4 5 6 7 8 9 10 11
#include "p2.h"
// example program: main2_1.cc
int main ()
{
P2_GRADES g; // instantiate an object g of class P2_GRADES
g.P2_REPORT(1111, 11, -1);
g.P2_SORT();
return 0;
}