#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<conio.h>
#include<windows.h>
struct dat
{
int d,m;
};
int clscanf();
struct student
{
struct dat dt;
float f,fine,tot,adv,due;
char n[50];
int r,c;
} stud,s;
struct teacher
{
struct dat dt;
char n[50];
float sal,adv,tot;
int id,no;
} tech,t;
int chkdat(int,int);// for checking date
void addrec(int);//for adding records
void modrec(int);//for modifying records
void searchrec(int);//for searching records
void delrec(int);//for deleting records
void salary(int);//for the calculation of salary of teacher and staff
FILE *fs,*ft;//file declaration
int mm,dd;//mm=month, dd=day
void ext();//for exiting
void main(void)
{
int i,j,k;
for(i=0; i<80; i++)
{
printf("\xdb");
}
printf("\n");
for(i=0; i<80; i++)
{
printf("\xdb");
}
printf(" \t____________________________________________\n");
printf("\t| |\n");
printf("\t| WELCOME TO SCHOOL BILLING SYSTEM |\n");
printf("\t| |\n");
printf("\t| |\n");
printf(" \t____________________________________________\n");
printf("\n\tPLEASE ENTER ANY KEY TO CONTINUE");
for(i=0; i<5; i++)
{
printf(".");
Sleep(500);
}
getch();
system("cls");
printf("\n");
for(i=0; i<80; i++)
{
printf("\xdb");
}
printf("\n\n\t** WELCOME SCHOOL BILLING SYSTEM **\n\n\n");
for(i=0; i<80; i++)
{
printf("\xdb");
}
printf("\nPLEASE ENTER ANY KEY TO START\n");
for(i=0; i<5; i++)
{
printf(".");
Sleep(500);
}
fflush(stdin);
getch();
system("cls");
printf("\n\t\tPLEASE ENTER CURRENT DATE\nmm dd\n ");
scanf("%d%d",&mm,&dd);
mm=chkdat(mm,dd);
start();
}
void start()
{
int i,j;//j is for selection of account type
system("cls");
printf("\n\t\tPLEASE ENTER ACCOUNT TYPE");
printf("\n\t\t1:: Student");
printf("\n\t\t2:: Teachers and Staffs");
printf("\n\t\t3:: Exit");
printf("\n\t\tAccount type choice ");
fflush(stdin);
scanf("%d",&j);
switch (j)
{
case 3:
ext();
case 1:
{
system("cls");
printf("\n\t\tPLEASE ENTER THE CHOICE");
printf("\n\t\t1:: Add record");
printf("\n\t\t2:: Search record");
printf("\n\t\t3:: Modify record");
printf("\n\t\t4:: Delete record");
printf("\n\t\t5:: Calculate fee");
printf("\n\t\t6:: Exit");
printf("\n\n Enter choice ");
fflush(stdin);
scanf("%d",&i);
switch (i)
{
case 1:
addrec(j);//function call
start();//function call
case 2:
searchrec(j);
start();
case 3:
modrec(j);
start();
case 4:
delrec(j);
start();
case 5:
fee(mm);
start();
case 6:
ext();
default :
{
printf("\n\n\tInvalid entry!!");
printf("\n\nTo Account Type\n\n\t");
system("pause");
start();
}
}
}
case 2:
{
system("cls");
printf("\n\t\tPLEASE ENTER THE CHOICE");
printf("\n\t\t1:: Add record");
printf("\n\t\t2:: Search record");
printf("\n\t\t3:: Modify record");
printf("\n\t\t4:: Delete record");
printf("\n\t\t5:: Calculate Salary");
printf("\n\t\t6:: Exit");
printf("\n\n Enter choice ");
fflush(stdin);
scanf("%d",&i);
switch (i)
{
case 1:
addrec(j);
start();
case 2:
searchrec(j);
start();
case 3:
modrec(j);
start();
case 4:
delrec(j);
case 5:
salary(mm);
start();
case 6:
ext();
default :
{
printf("\n\n\tInvalid entry!!");
printf("\n\nTo Account Type\n\n\t");
system("pause");
start();
}
}
}
default :
{
printf("\n\n\tInvalid entry!!");
printf("\n\nTo Account Type\n\n\t");
system("pause");
start();
}
}
}
void addrec(int j)
{
int dif,cdat,ddat,month=0;//cdat=month till which fee is cleared
float ff;//used in calculatin of fee of different class
char c='y';
system("cls");
printf("\n\t******************************************************************");
printf("\n\t *************************** ");
printf("\n\t********************* ADD RECORD *******************");
printf("\n\t *************************** ");
printf("\n\t******************************************************************");
if (j==1)
{
while(c=='y'||c=='Y')
{
int a=1;
printf("\n\nEnter the name of student: ");
fflush(stdin);
scanf("%[^\n]",stud.n);
printf("\nEnter the class: ");
fflush(stdin);
stud.c=clscanf();
printf("\nEnter the Roll No.:");
fflush(stdin);
scanf("%2d",&stud.r);
printf("\nEnter month and day till which fee is paid:");
fflush(stdin);
scanf("%2d%2d",&cdat,&ddat);
cdat=chkdat(cdat,ddat);
stud.dt.m=cdat;
ff=stud.c/10.0;
stud.f=1000*(1+ff);//fee of different classes
dif=mm-stud.dt.m;//months of fee left to be paid
stud.fine=(dif*stud.f)*1/100;
stud.due=(dif)*stud.f;//fees left to be paid
if(dif==1)
{
stud.tot=stud.f;
stud.fine=0;
}
else
{
stud.tot=stud.fine+stud.due;
}//for calculation of total fee
fs=fopen("student","ab+");//opening a binary file in apend mode
fwrite(&stud,sizeof(stud),1,fs);
fclose(fs);
printf("\n\nDo you want to continue with the process(press y or Y");
fflush(stdin);
c=getch();
}
getch();
}
if (j==2)
{
while(c=='y'||c=='Y')
{
int a=1;
printf("\n\nEnter name of teacher/staff:" );
fflush(stdin);
scanf("%[^\n]",tech.n);
printf("\nEnter teacher/staff id: ");
fflush(stdin);
scanf("%d",&tech.id);
printf("\nEnter number of class/shift per month:: ");
scanf("%d",&tech.no);
fflush(stdin);
printf("\nEnter month and day till which salary is paid::");
scanf("%d %d",&tech.dt.m,&tech.dt.d);
cdat=chkdat(cdat,ddat);
tech.dt.m=cdat;
tech.sal=tech.no*500;
tech.adv=(tech.dt.m-mm-1)*tech.sal;
if (tech.adv<0) tech.adv=0;
tech.tot=tech.sal;
ft=fopen("teacher","ab+");
fwrite(&tech,sizeof(tech),1,ft);
fclose(ft);
printf("\n\nDo you want to continue with the process(press y or Y");
fflush(stdin);
c=getch();
}
fflush(stdin);
printf("\n\n");
system("pause");
}
}
void searchrec(int j)
{
char name[50],namet[50];
int a=1,choice;
char c='y';
if (j==1)
{
while(c=='y'||c=='Y')