#include<iostream.h>
#include<fstream.h>//header file
#include<string>
#include<stdlib.h>
void main()
{
fstream pasca;
pasca.open("C:evaluate.dat",ios::out);
fstream display;
paparan.open("C:evaluate.dat",ios::in);
int lecturer_code;
int course_code;
char gred1, gred2, gred3, gred4, gred5;
float point1, point2, point3, point4, point5;
float total_point1, total_point2, total_point3, total_point4, total_point5;
char user;
if(!pasca || !display)
{
cout<<"File cannot open";
exit(1);
}
cout<<"Enter Lecturer code (in number): ";
cin>>lecturer_code;
cout<<"Enter course code (in number): ";
cin>>course_code;
int bil = 0;
do
{
cout<<"Grade question 1: ";
cin>>gred1;
if(gred1 == 'A' || gred1 == 'a')
{point1 = 4;
point1++;
}
else if(gred1 == 'B' || gred1 == 'b')
{point1 = 3;
point1++;
}
else if(gred1 == 'C' || gred1 == 'c')
{point1 = 2;
point1++;
}
else if(gred1 == 'D' || gred1 == 'd')
{point1 = 1;
point1++;
}
else if(gred1 == 'E' || gred1 == 'e')
{point1 = 0;
point1++;
}
cout<<"Grade question 2: ";
cin>>gred2;
if(gred2 == 'A' || gred2 == 'a')
{point2 = 4;
point2++;
}
else if(gred2 == 'B' || gred2 == 'b')
{point2 = 3;
point2++;
}
else if(gred2 == 'C' || gred2 == 'c')
{point2 = 2;
mata2++;
}
else if(gred2 == 'D' || gred2 == 'd')
{point2 = 1;
point2++;
}
else if(gred2 == 'E' || gred2 == 'e')
{mata2 = 0;
point2++;
}
cout<<"Grade question 3: ";
cin>>gred3;
if(gred3 == 'A' || gred3 == 'a')
{point3 = 4;
point3++;
}
else if(gred3 == 'B' || gred3 == 'b')
{point3 = 3;
point3++;
}
else if(gred3 == 'C' || gred3 == 'c')
{point3 = 2;
point3++;
}
else if(gred3 == 'D' || gred3 == 'd')
{point3 = 1;
point3++;
}
else if(gred3 == 'E' || gred3 == 'e')
{point3 = 0;
point3++;
}
cout<<"Grade question 4: ";
cin>>gred4;
if(gred4 == 'A' || gred4 == 'a')
{point4 = 4;
point4++;
}
else if(gred4 == 'B' || gred4 == 'b')
{point4 = 3;
point4++;
}
else if(gred4 == 'C' || gred4 == 'c')
{point4 = 2;
point4++;
}
else if(gred4 == 'D' || gred4 == 'd')
{point4 = 1;
point4++;
}
else if(gred4 == 'E' || gred4 == 'e')
{point4 = 0;
point4++;
}
cout<<"Grade question 5: ";
cin>>gred5;
if(gred5 == 'A' || gred5 == 'a')
{point5 = 4;
point5++;
}
else if(gred5 == 'B' || gred5 == 'b')
{point5 = 3;
point5++;
}
else if(gred5 == 'C' || gred5 == 'c')
{point5 = 2;
point5++;
}
else if(gred5 == 'D' || gred5 == 'd')
{point5 = 1;
point5++;
}
else if(gred5 == 'E' || gred5 == 'e')
{point5 = 0;
point5++;
}
pasca<<lecturer_code<<" "<<course_code<<" "<<gred1<<" "<<gred2<<" "<<gred3<<" "<<gred4<<" "<<gred5<<"\n"<<endl;
bil++;
cout<<"Do u want to continue (Y-yes / N-no): "<<endl;
cin>>user;
}while (user == 'Y' || user == 'y');
cout<<"\t\tEvaluation Details"<<endl;
cout<<"\n\nLecturer\t\t:"<<kod_pensyarah<<endl;
cout<<"Course\t\t\t:"<<kod_kursus<<endl;
cout<<"Bil student\t:"<<bil<<endl;
cout<<"Average:\t"<<endl;
total_point1 = (point1 / bil);
cout<<"\tquestion 1 \t:"<<total_point1<<endl;
total_point2 = (point2 / bil);
cout<<"\tquestion 2\t:"<<total_point2<<endl;
total_point3 = (point3 / bil);
cout<<"\tquestion 3\t:"<<total_point3<<endl;
total_point4 = (point4 / bil);
cout<<"\tquestion 4\t:"<<total_point4<<endl;
total_point5 = (point5 / bil);
cout<<"\tquestion 5\t:"<<total_point5<<endl;
display.close();
pasca.close();
}
Hayati_mahamad
0
Newbie Poster
Recommended Answers
Jump to PostForget the computer for a bit. Think of the algorithm. How would you do it with pencil and paper? What steps would you take? Write the steps out exactly. Follow the steps exactly to make sure they are right for all scenarios.
Now go back to the code and make …
Jump to PostHi Hayati_mahamad, the problem is, the total for point1 to point 5 are not getting accumulated, in the sense, as you can see in the optput, the average is the points entered for the last student divided by number of students, as per the attachment - (points of student 2/2).
…
All 7 Replies
Hayati_mahamad
0
Newbie Poster
Hayati_mahamad
0
Newbie Poster
VernonDozier
2,218
Posting Expert
Featured Poster
rohit.deshmukh2009
0
Newbie Poster
Hayati_mahamad
0
Newbie Poster
rohit.deshmukh2009
0
Newbie Poster
Hayati_mahamad
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.