Dec 9, 2011 at 2:25am UTC
So, there is my coding, but i use, if else, BUT the one suppose is Function...
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.h>
#include<string.h>
int main()
{
char lect_name[30],subject[30];
char grade,status;
int mark;
int numbof_student;
float sum=0;
float average;
cout<<"Enter Your Lecturer name : " ;
cin>>lect_name;
cout<<"Enter Your Subject code : " ;
cin>>subject;
cout<<"Enter Number Of Student : " ;
cin>>numbof_student;
for (int s=0; s<numbof_student; s++)
{
cout<<s+1<<" student enter grade:" ;
cin>>grade;
if (grade=='A' )
{
mark=4;
}
else if (grade=='B' )
{
mark=3;
}
else if (grade=='C' )
{
mark=2;
}
else if (grade=='D' )
{
mark=1;
}
else
{
cout<<"Wrong Input" <<endl;
}
sum=sum+mark;
average=sum/numbof_student;
if ((average>=3.5) &&(average<=4.0))
{
cout<<"Excellence" ;
}
else if ((average<=3.0) &&(average<=3.5))
{
cout<<"Good" ;
}
else if ((average<=2.0) &&(average<=3.0))
{
cout<<"Average" ;
}
else if (average<=2.0)
{
cout<<"Poor" ;
}
}
cout<<"\n\n\t\tUniversiti Pendidikan Sultan Idris" ;
cout<<"\n\n\t\tTeaching & Learning Evaluation Report" ;
cout<<"\n\nName : " <<lect_name<<endl;
cout<<"Subject Code : " <<subject<<endl;
cout<<"Average :" <<average<<endl;
cout<<"Status : " <<status<<endl;
}
i did coding for function, but blablabla... still error and error and then hard i try the simplest coding...
UPDATE:
NO ONE HELP!
Currently im working it, but yet function problemt...
Last edited on Dec 9, 2011 at 3:12am UTC
Dec 9, 2011 at 4:36am UTC
1) There are no .h's on the header files
2) Because sum is a float it must be initialized with (in your case) 0.0
3) May I suggest that since you are using <string> instead of char var_name [digit#], do string var_name for the same effect, and change all cin's that you use for the char arrays to getline(cin, var_name)
4) you need using namespace std;
5) you can't divide an int by a float
6)having the if statements 54-69 since you have each one's max being the same as the previous minimum, it will print two responses
Dec 9, 2011 at 9:33am UTC
i had submit,
yes, not above there, i did my function coding...
i had done my assignment with non-stop working...
without any help!
but yet, TQ