How do i store students data in 6 different files. show the time they arrive for school. rank them by there grades. student's data must be store using a structure
Printable View
How do i store students data in 6 different files. show the time they arrive for school. rank them by there grades. student's data must be store using a structure
That's pretty much all you need for this. Isn't C great?Code:#include<stdhomework.h>
Quzah.
so what else u need to do
We try to help people with actual code. If you REALLY have no idea, then you need to review your chapters in the book, along with your class notes, and other programs you've written. The C tutorial link near the top of the forum, may be a big help, as well.
It's disconcerting to have someone ask for help to overhaul their car's engine, when you find out they barely know a screwdriver from a socket.
In any case, if you want help with pseudo code, post what you have, and ask specific questions about what you need help with. If you want help with a program, post your code, and ask specific questions so we know what you're stuck on.
But we don't take an assignment and start writing up code for people.
Read the Homework announcement.
> so what else u need to do
Dumbass.
clam down memcpy:mad:
Do you want the data stored in one Structure, then distributed to 6 different files?
yep i do
Where is the data coming from, is the user supposed to enter in all the data and then you store it?
Code:#include<stdio.h>
#include<time.h>
#include<math.h>
int avg(int x, int y, int a);//Funcation prototype to find average
int oavg(int x, int y, int b, int a);// Function prototype to the overall grade average
/*student data Structure definition*/
struct studentdata{
float egrade;//Students english grade for term 1
float mgrade;//Students math grade for term 1
float egrade1;//Students english grade for term 2
float mgrade1;//Students math grade for term 2
float egrade2;//Students english grade term 3
float mgrade2;//Students math grade term 3
char sex[9];//Gender
char fname[30];//first name
char lname[30];//last name
int age;//Age
int schfee;//School fee payment
char pa[2];//To show pm or am
int late;//The amount time student was late
int abs;//Amount time student was abscent
float z;//Use to hold the values of the averages when calculating the averages
float a1;//Term 1 average grade
float a2;//Term 2 average grade
float a3;//Final term average grade
float oga;//Overll grade averAge
int id;//Identification Number
};
int main(void)
{
FILE *gradeI;
FILE *gradeII;
FILE *gradeIII;
FILE *gradeIV;
FILE *gradeV;
FILE *gradeVI;
int i=0;
struct studentdata student;//Declaration of structure student data as student
char pa;
int m;
int hours;
int minutes;
if ((gradeI=fopen("Grade 1 Students.dat","w"))==NULL){
printf("File could not be opened\n");
}
if((gradeII=fopen("Grade 2 Students.dat","w"))==NULL){
printf("File could not be opened\n");
}
if((gradeIII=fopen("Grade 3 Students.dat","w"))==NULL){
printf("File could not be opened\n");
}
if((gradeIV=fopen("Grade 4 Students.dat","w"))==NULL){
printf("File could not be opened\n");
}
if((gradeV=fopen("Grade 5 Students.dat","w"))==NULL){
printf("File could not be opened\n");
}
if((gradeVI=fopen("Grade 6 Students.dat","w"))==NULL){
printf("File could not be opened\n");
}
else{
student.id=1000;
fprintf(gradeI,"\t\t##################################\n"
"\t\t#### Grade I STUDENTS DATA ###\n"
"\t\t##################################\n");
fprintf(gradeII,"\t\t##################################\n"
"\t\t#### Grade II STUDENTS DATA ###\n"
"\t\t##################################\n");
fprintf(gradeIII,"\t\t#################################\n"
"\t\t#### Grade III STUDENTS DATA ###\n"
"\t\t#################################\n");
fprintf(gradeIV,"\t\t##################################\n"
"\t\t#### Grade IV STUDENTS DATA ####\n"
"\t\t##################################\n");
fprintf(gradeV,"\t\t##################################\n"
"\t\t#### Grade V STUDENTS DATA ###\n"
"\t\t##################################\n");
fprintf(gradeVI,"\t\t##################################\n"
"\t\t#### Grade VI STUDENTS DATA #####\n"
"\t\t##################################\n");
printf("enter the amount of students data you are entring into the progam:");
scanf("%d",&m);
while(m!= 0){
i++;
m--;
system("color a3");
printf("\nEnter first and last name:");
scanf("%s %s",student.fname,student.lname);
printf("Enter age:");
scanf("%d",&student.age);
printf("Enter Gender:");
scanf("%s",student.sex);
printf("\n*****Term One*****\n");
printf("Enter student average English Grade:");
scanf("%f",&student.egrade);
printf("Enter Student average Math Grade:");
scanf("%f",&student.mgrade);
printf("\n*****Term two*****\n");
printf("Enter student average English Grade:");
scanf("%f",&student.egrade1);
printf("Enter Student average Math Grade:");
scanf("%f",&student.mgrade1);
printf("\n*****Final Term*****\n");
printf("Enter student average English Grade:");
scanf("%f",&student.egrade2);
printf("Enter Student average Math Grade:");
scanf("%f",&student.mgrade2);
printf("Enter amount paid for school:");
scanf("%d",&student.schfee);
/* printf("Enter the times student arrives at in standard time:");
scanf("%d",&hours,&minutes,pa);*/
printf("How many times student was late for school?:");
scanf("%d",&student.late);
printf("How many time student was absecnt for school?:");
scanf("%d",&student.abs);
student.a1=avg(student.egrade,student.mgrade,student.z);
student.a2=avg(student.egrade1,student.mgrade1,student.z);
student.a3=avg(student.egrade2,student.mgrade2,student.z);
student.oga=oavg(student.a1, student.a2, student.a3,student.z);
system("cls");
switch(student.age){
case 6:
fprintf(gradeI,"***************************************************************\n");
fprintf(gradeI,"****ID#:%d\n"
"****First Name:%s\n"
"****Last Name:%s \n"
"****Age:%d\n"
"****Gender:%s\n",student.id+i,student.fname,student.lname,student.age,student.sex);
//scanf("%d%s%s%d",&i,student.fname,student.lname,&student.age);
fprintf(gradeI,"**** Student school grade information\n");
fprintf(gradeI,"****Term 1 average grade is %.2f\n"
"****Term 2 average grade is %.2f\n"
"****Final term Average is %.2f\n"
"****Overall grade avergae for the school year is %.2f\n",student.a1,student.a2,student.a3, student.oga);
fprintf(gradeI,"****\n**** Information on the arrival time for the day\n"
"****Time:%d:%d%s\n",hours,minutes,pa);
if(student.oga>=80){
fprintf(gradeI,"****\n****Student Receives Cash Prize becauuse for High End Year Grade average\n");
}
if (student.schfee!=7500){
fprintf(gradeI,"****\n****Parent/s or guardian/s need to be call in concerning the school fee\n");
}
fprintf(gradeI,"***************************************************************\n\n");
break;
case 7:
fprintf(gradeII,"\n\n***************************************************************\n");
fprintf(gradeII,"****ID#:%d\n"
"****First Name:%s\n"
"****Last Name:%s\n"
"****Age:%d\n"
"****Gender:%s\n",student.id+i,student.fname,student.lname,student.age,student.sex);
fprintf(gradeII,"**** Student school grade information\n");
fprintf(gradeII,"****Term 1 average grade is %.2f\n"
"****Term 2 average grade is %.2f\n"
"****Final term Average is %.2f\n"
"****Overall grade avergae for the school year is %.2f\n",student.a1,student.a2,student.a3, student.oga);
fprintf(gradeII,"****\n**** Information on the arrival time for the day\n"
"****Time:%d:%d%s\n",hours,minutes,pa);
if(student.oga>=80){
fprintf(gradeII,"****\n****Student Receives Cash Prize becauuse for High End Year Grade average\n");
}
if (student.schfee!=7500){
fprintf(gradeII,"****\n****Parent/s or guardian/s need to be call in concerning the school fee\n");
}
fprintf(gradeII,"***************************************************************\n\n");
break;
case 8:
fprintf(gradeIII,"\n\n**************************************************************\n");
fprintf(gradeIII,"****ID#:%d\n"
"****First Name:%s\n"
"****Last Name:%s\n"
"****Age:%d\n"
"****Gender:%s\n",student.id+1,student.fname,student.lname,student.age,student.sex);
fprintf(gradeIII,"**** Student school grade information\n");
fprintf(gradeIII,"****Term 1 average grade is %.2f\n"
"****Term 2 average grade is %.2f\n"
"****Final term Average is %.2f\n"
"****Overall grade avergae for the school year is %.2f\n",student.a1,student.a2,student.a3, student.oga);
fprintf(gradeIII,"**** Information on the arrival time for the day\n"
"****Time:%d:%d%s\n",hours,minutes,pa);
if(student.oga>=80){
fprintf(gradeIII,"****\n****Student Receives Cash Prize becauuse for High End Year Grade average\n");
}
if (student.schfee!=7500){
fprintf(gradeIII,"****\n****Parent/s or guardian/s need to be call in concerning the school fee\n");
}
fprintf(gradeIII,"**************************************************************\n\n");
break;
case 9:
fprintf(gradeIV,"**************************************************************\n");
fprintf(gradeIV,"****ID#:%d\n"
"****First Name:%s\n"
"****Last Name:%s\n"
"****Age:%d\n"
"****Gender:%s\n",student.id+i,student.fname,student.lname,student.age,student.sex);
fprintf(gradeIV,"**** Student school grade information\n");
fprintf(gradeIV,"****Term 1 average grade is %.2f\n"
"****Term 2 average grade is %.2f\n"
"****Final term Average is %.2f\n"
"****Overall grade avergae for the school year is %.2f\n",student.a1,student.a2,student.a3, student.oga);
fprintf(gradeIV,"****\n**** Information on the arrival time for the day\n"
"****Time:%d:%d%s\n",hours,minutes,pa);
if(student.oga>=80){
fprintf(gradeIV,"****\n****Student Receives Cash Prize becauuse for High End Year Grade average\n");
}
if (student.schfee!=7500){
fprintf(gradeIV,"****\n****Parent/s or guardian/s need to be call in concerning the school fee\n");
}
fprintf(gradeIV,"**************************************************************\n\n");
break;
case 10:
fprintf(gradeV,"***************************************************************\n");
fprintf(gradeV,"****ID#:%d\n"
"****First Name:%s\n"
"****Last Name:%s\n"
"****Age:%d\n"
"****Gender:%s\n",student.id+i,student.fname,student.lname,student.age,student.sex);
fprintf(gradeV,"**** Student school grade information\n");
fprintf(gradeV,"****Term 1 average grade is %.2f\n"
"****Term 2 average grade is %.2f\n"
"****Final term Average is %.2f\n"
"****Overall grade avergae for the school year is %.2f\n",student.a1,student.a2,student.a3, student.oga);
fprintf(gradeV,"****\n**** Information on the arrival time for the day\n"
"****Time:%d:%d%s\n",hours,minutes,pa);
if(student.oga>=80){
fprintf(gradeV,"****\n****Student Receives Cash Prize becauuse for High End Year Grade average\n");
}
if (student.schfee!=7500){
fprintf(gradeV,"***\n****Parent/s or guardian/s need to be call in concerning the school fee\n");
}
fprintf(gradeV,"***************************************************************\n\n");
break;
case 11:
case 12:
fprintf(gradeVI,"\n\n***************************************************************\n");
fprintf(gradeVI,"****ID#:%d\n"
"****First Name:%s\n"
"****Last Name:%s\n"
"****Age:%d\n"
"****Gender:%s\n",student.id+i,student.fname,student.lname,student.age,student.sex);
fprintf(gradeVI,"**** Student school grade information\n");
fprintf(gradeVI,"****Term 1 average grade is %.2f\n"
"****Term 2 average grade is %.2f\n"
"****Final term Average is %.2f\n"
"****Overall grade avergae for the school year is %.2f\n",student.a1,student.a2,student.a3, student.oga);
fprintf(gradeVI,"****\n**** Information on the arrival time for the day\n"
"****Time:%d:%d%s\n",hours,minutes,pa);
if(student.oga>=80){
fprintf(gradeVI,"****\n****Student Receives Cash Prize becauuse for High End Year Grade average\n");
}
if (student.schfee!=7500){
fprintf(gradeVI,"****\n****Parent/s or guardian/s need to be call in concerning the school fee\n");
}
fprintf(gradeVI,"***************************************************************\n\n");
break;
default:
printf("Age is not suitable for the primary school.");
break;
system("cls");
}
}
fclose(gradeI);
fclose(gradeII);
fclose(gradeIII);
fclose(gradeIV);
fclose(gradeV);
fclose(gradeVI);
}
getch();
return 0;
}
int avg(int x, int y, int a){
a=(x+y)/2;
}
int oavg(int x, int y, int b, int a){
a=(x+y+b)/3;
}
yes thats the plan
yes it is comming from the user
How do i put a function prototype and definition within this program to rank the students base on there grades
Where did you get that code from?
Did you copy/paste the code from case 6 to case 7 ?
Was the only edit to change gradeI into gradeII ?
If so, then make it a function where you pass say
outputRecord( gradeI, student );
and make the code a hell of a lot shorter into the process.