Professional Documents
Culture Documents
INTRODUCTION
• SCOPE
IN-SCOPE
OUT OF SCOPE
• OVERVIEW
• TEST CASES
• OUTPUT
. College attendance
Introduction:
Purpose:
Out of scope:
We can’t exit the project directly in between.
4) Exit:
If the user wants to exit from the project he/she will
use this option.
void mainmenu()
{
printf("\t\t\t\t WELCOME\n");
printf("\t\t GLAD THAT YOU ARE READY TO USE OUR
SOFTWARE\n\n");
printf("\t\t\t MAIN MENU \t\t\t\n");
printf("\t\t\t 1) Enter the attendance:\n");
printf("\t\t\t 2) Add new student information: \n");
printf("\t\t\t 3) View the attendance\n");
printf("\t\t\t 4) EXIT\n");
printf("enter choice:");
}
int program()
{
FILE *cfptr;
int choice=0;
char opt='n';
while(choice<5)
{
choice = enterchoice();
switch(choice)
{
case 1:
updaterecord();
break;
case 2:
cfptr=fopen("student.dat","ab+");
newrecord(cfptr);
fclose(cfptr);
break;
case 3:
read();
break;
case 4:
printf("EXIT");
break;
default:
printf("\nInvalid choice\n");
mainmenu();
program();
}
return 0;
}
}
int main(void)
{
mainmenu();
program();
}
void updaterecord()
{
int stdnt;
char opt='y';
double transaction;
double trans;
struct stdtdata student = {0,"","",0.0,0.0};
FILE *fptr;
while (opt=='y')
{
fptr=fopen("student.dat","rb+");
printf("Enter student no.to be updated: ");
scanf("%d", &stdnt);
fseek(fptr, (stdnt - 1) * sizeof(struct stdtdata),SEEK_SET);
fread(&student , sizeof(struct stdtdata),1,fptr);
if(student .stnum ==0)
{
printf("given student id does not have any
information.\n\n", stdnt);
}
else
{
printf("%5d%5s%5s%15f%15f\n\n", student.stnum,
student.lastname, student .firstname, student .total,student .balance);
else
{
printf("Enter lastname, firstname, attendance:\n");
scanf("%s%s%f",student .lastname, student .firstname,
&student .balance);
student .stnum = stdntnum;
fseek(fptr, (student .stnum -1) * sizeof(struct stdtdata),
SEEK_SET);
fwrite(&student , sizeof(struct stdtdata), 1, fptr);
printf("do u want to update another new record?if yes press y or
else n\n");
scanf("%s",&opt);
if ( opt=='y')
{
cfptr=fopen("student.dat","ab+");
newrecord(cfptr);
fclose(cfptr);
}
else if (opt=='n')
{
mainmenu();
program();
}
else
{
printf("invalid choice press y or n:");
scanf("%s",&opt);
}
}
}
int enterchoice()
{
int menuchoice;
scanf("%d", &menuchoice);
return menuchoice;
}
void read()
{
float percentage;
FILE *readptr;
struct stdtdata student ;
readptr = fopen("student.dat", "rb+");
if (readptr == NULL)
{
printf("\nCannot open file");
}
else
{
printf("\ncan read the file\n");
printf("id lastname firstname Workingdays
Attendance Percentage\n");
while(!feof(readptr))
{
int i=fread(&student , sizeof(struct stdtdata),1, readptr);
percentage=(student.balance/student.total)*100;
if(i==1)
{
#include <stdio.h>
#include <conio.h>
struct clientdata
{
int stnum;
char lastname[12];
char firstname[10];
float balance;
float total;
};
void main()
{
printf("\nin textfile");
FILE *writeptr;
int i=1;
struct clientdata client = {0,"shalini","5030",0.0};
writeptr = fopen("student.dat", "wb");
if ( writeptr == NULL)
{
printf("\nCannot open the file.");
}
else
{
printf("Enter no. of working days:");
scanf("%f",&client.total);
while(i==1)
{
printf("\nENter student id #:");
scanf("%d",&client.stnum);
printf("\nEnter Last Name:");
scanf("%s",&client.lastname);
printf("\nEnter First Name:");
scanf("%s",&client.firstname);
printf("\nEnter attendance:");
scanf("%f",&client.balance);
fseek(writeptr, (client.stnum -1) * sizeof(struct clientdata),
SEEK_SET);
fwrite(&client, sizeof(struct clientdata),1,writeptr);
printf("do u want to enter one more record yes=1, no=0");
scanf("%d",&i);
}
}
fclose(writeptr);
}