CS/IT Project: Wisdom College Hostel Management System Implementation
VerifiedAdded on  2023/03/31
|25
|1266
|447
Project
AI Summary
This document details a C programming project for a hostel management system designed for Wisdom College. The system encompasses several key functionalities, including adding student records, checking room availability based on gender, calculating total payments based on room type and duration of stay, and displaying student details. The code includes functions for adding new student entries to a database, checking room availability in different blocks, calculating the total payment, and displaying student information. The payment section provides different options and allows the user to abort the payment process. The project is designed to manage student accommodation, room allocation, and associated financial transactions within the hostel environment. The provided source code snippets demonstrate the implementation of these features, offering a practical example of how to develop a functional hostel management system using C programming. The project also includes previews of the different functionalities and the source codes of the different functions implemented.
Contribute Materials
Your contribution can guide someone’s learning journey. Share your
documents today.

Running Head: HOSTEL MANAGEMENT SYSTEM
HOSTEL MANAGEMENT SYSTEM
Name of the Student:
Name of the University:
Author Note:
HOSTEL MANAGEMENT SYSTEM
Name of the Student:
Name of the University:
Author Note:
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.

1HOSTEL MANAGEMENT SYSTEM
Table of Contents
Source Codes...................................................................................................................................2
Add student entry.........................................................................................................................2
Check availability of rooms according to gender........................................................................9
Total payment to be made..........................................................................................................13
Check Student details................................................................................................................15
Payment options and to cancel the payment in mid-way..........................................................19
Table of Contents
Source Codes...................................................................................................................................2
Add student entry.........................................................................................................................2
Check availability of rooms according to gender........................................................................9
Total payment to be made..........................................................................................................13
Check Student details................................................................................................................15
Payment options and to cancel the payment in mid-way..........................................................19

2HOSTEL MANAGEMENT SYSTEM
Source Codes
Add student entry
This function is used to add student records to the data file or .dat file that is used in the program.
There are structures made to take input from the user for the date and one for the student details.
The name of the function is new_entry(), the variables that are used is an integer variable named
as choice. FILE defines the two file pointers as *ptr and *hostel.
Source Code to Add student entry:
int new_entry()
{
int choice;
FILE *ptr,*hostel;
ptr=fopen("student_record.dat","a+");
printf("\t\t\t\******* ADD STUDENTS DATA *******\n");
printf("\nEnter student Id:");
scanf("%s",check.student_id);
while(fscanf(ptr,"%s %s %d/%d/%d %d %s %d %s %s %d %s\n",add.student_id, add.name,
&add.dob.month, &add.dob.day, &add.dob.year, &add.age, add.city, &add.phone, add.mail_id,
add.father_name, &add.father_phone, add.hostel_name)!=EOF)
Source Codes
Add student entry
This function is used to add student records to the data file or .dat file that is used in the program.
There are structures made to take input from the user for the date and one for the student details.
The name of the function is new_entry(), the variables that are used is an integer variable named
as choice. FILE defines the two file pointers as *ptr and *hostel.
Source Code to Add student entry:
int new_entry()
{
int choice;
FILE *ptr,*hostel;
ptr=fopen("student_record.dat","a+");
printf("\t\t\t\******* ADD STUDENTS DATA *******\n");
printf("\nEnter student Id:");
scanf("%s",check.student_id);
while(fscanf(ptr,"%s %s %d/%d/%d %d %s %d %s %s %d %s\n",add.student_id, add.name,
&add.dob.month, &add.dob.day, &add.dob.year, &add.age, add.city, &add.phone, add.mail_id,
add.father_name, &add.father_phone, add.hostel_name)!=EOF)

3HOSTEL MANAGEMENT SYSTEM
{
if (strcmp(check.student_id,add.student_id)==0)
{printf("Students Id already in use!");
goto student_id;
}
}
strcpy(add.student_id,check.student_id);
printf("\nEnter the name:");
scanf("%s",add.name);
printf("\nEnter the date of birth(mm/dd/yyyy):");
scanf("%d/%d/%d",&add.dob.month,&add.dob.day,&add.dob.year);
printf("\nEnter the age:");
scanf("%d",&add.age);
printf("\nEnter the city:");
scanf("%s",add.city);
printf("\nEnter the phone number: ");
scanf("%d",&add.phone);
{
if (strcmp(check.student_id,add.student_id)==0)
{printf("Students Id already in use!");
goto student_id;
}
}
strcpy(add.student_id,check.student_id);
printf("\nEnter the name:");
scanf("%s",add.name);
printf("\nEnter the date of birth(mm/dd/yyyy):");
scanf("%d/%d/%d",&add.dob.month,&add.dob.day,&add.dob.year);
printf("\nEnter the age:");
scanf("%d",&add.age);
printf("\nEnter the city:");
scanf("%s",add.city);
printf("\nEnter the phone number: ");
scanf("%d",&add.phone);
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.

4HOSTEL MANAGEMENT SYSTEM
printf("\n Enter your email id :");
scanf("%s",add.mail_id);
printf("\n Enter your Father's name:");
scanf("%s",add.father_name);
printf("\n Enter your Father's phone no.:");
scanf("%d",&add.father_phone);
printf("\n Enter your hostel name from A3, B1, B3, B4 :");
scanf("%s",add.hostel_name);
fprintf(ptr,"%s %s %d/%d/%d %d %s %d %s %s %d %s %s\n",add.student_id, add.name,
add.dob.month, add.dob.day, add.dob.year, add.age, add.city, add.phone, add.mail_id,
add.father_name, add.father_phone, add.hostel_name);
//adding student Ids to hostels' list
if(strcmp(add.hostel_name,"A3")==0)
{
hostel=fopen("A3.dat","a+");
fprintf(hostel, "%s\n", add.student_id);
fclose(hostel);
}
printf("\n Enter your email id :");
scanf("%s",add.mail_id);
printf("\n Enter your Father's name:");
scanf("%s",add.father_name);
printf("\n Enter your Father's phone no.:");
scanf("%d",&add.father_phone);
printf("\n Enter your hostel name from A3, B1, B3, B4 :");
scanf("%s",add.hostel_name);
fprintf(ptr,"%s %s %d/%d/%d %d %s %d %s %s %d %s %s\n",add.student_id, add.name,
add.dob.month, add.dob.day, add.dob.year, add.age, add.city, add.phone, add.mail_id,
add.father_name, add.father_phone, add.hostel_name);
//adding student Ids to hostels' list
if(strcmp(add.hostel_name,"A3")==0)
{
hostel=fopen("A3.dat","a+");
fprintf(hostel, "%s\n", add.student_id);
fclose(hostel);
}

5HOSTEL MANAGEMENT SYSTEM
else if(strcmp(add.hostel_name,"B1")==0)
{
hostel=fopen("B1.dat","a+");
fprintf(hostel, "%s\n", add.student_id);
fclose(hostel);
}
else if(strcmp(add.hostel_name,"B3")==0)
{
hostel=fopen("B3.dat","a+");
fprintf(hostel, "%s\n", add.student_id);
fclose(hostel);
}
else if(strcmp(add.hostel_name,"B4")==0)
{
hostel=fopen("B4.dat","a+");
fprintf(hostel, "%s\n", add.student_id);
fclose(hostel);
}
else if(strcmp(add.hostel_name,"B1")==0)
{
hostel=fopen("B1.dat","a+");
fprintf(hostel, "%s\n", add.student_id);
fclose(hostel);
}
else if(strcmp(add.hostel_name,"B3")==0)
{
hostel=fopen("B3.dat","a+");
fprintf(hostel, "%s\n", add.student_id);
fclose(hostel);
}
else if(strcmp(add.hostel_name,"B4")==0)
{
hostel=fopen("B4.dat","a+");
fprintf(hostel, "%s\n", add.student_id);
fclose(hostel);
}

6HOSTEL MANAGEMENT SYSTEM
fclose(ptr);
printf("\nStudent added successfully!\n\n");
}
int gender()
{
char ch;
printf("Enter gender (M/m or F/f): ");
scanf("%c",&ch);
switch(ch)
{
case 'M':
case 'm':{
printf("Available blocks are A3.\n");
printf("Number of available rooms are: 100\n");
break;
fclose(ptr);
printf("\nStudent added successfully!\n\n");
}
int gender()
{
char ch;
printf("Enter gender (M/m or F/f): ");
scanf("%c",&ch);
switch(ch)
{
case 'M':
case 'm':{
printf("Available blocks are A3.\n");
printf("Number of available rooms are: 100\n");
break;
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

7HOSTEL MANAGEMENT SYSTEM
}
case 'F':
case 'f':{
char choice[2];
printf("Available blocks are B1, B3, B4.\n");
printf("Number of available rooms in B1: 100\n");
printf("Number of available rooms in B3: 100\n");
printf("Number of available rooms in B4: 100\n");
printf("Please choose your block:");
scanf("%s",choice);
if(choice[0]=='B' && choice[1]=='1')
printf("The rates are: Room=400, Meal=120, GYM=10");
else if(choice[0]=='B' && choice[1]=='3')
printf("The rates are: Room=150, Meal=120, GYM=10");
}
case 'F':
case 'f':{
char choice[2];
printf("Available blocks are B1, B3, B4.\n");
printf("Number of available rooms in B1: 100\n");
printf("Number of available rooms in B3: 100\n");
printf("Number of available rooms in B4: 100\n");
printf("Please choose your block:");
scanf("%s",choice);
if(choice[0]=='B' && choice[1]=='1')
printf("The rates are: Room=400, Meal=120, GYM=10");
else if(choice[0]=='B' && choice[1]=='3')
printf("The rates are: Room=150, Meal=120, GYM=10");

8HOSTEL MANAGEMENT SYSTEM
else if(choice[0]=='B' && choice[1]=='4')
printf("The rates are: Room=100, Meal=120, GYM=10");
else
printf("invalid choice");
break;
}
}
printf("\n");
}
else if(choice[0]=='B' && choice[1]=='4')
printf("The rates are: Room=100, Meal=120, GYM=10");
else
printf("invalid choice");
break;
}
}
printf("\n");
}

9HOSTEL MANAGEMENT SYSTEM
Previews:
Fig 1. Add Entry to the list
Check availability of rooms according to gender
The name of this function is gender(), and this function is used to input the gender of the student
and displays the available room options for the student. The character variable ch is used to take
the input of the gender as M/m for male and F/f for female. After that the function moves into the
switch case according to the option chosen.
Source Code to Check availability of rooms according to gender:
int gender()
{
Previews:
Fig 1. Add Entry to the list
Check availability of rooms according to gender
The name of this function is gender(), and this function is used to input the gender of the student
and displays the available room options for the student. The character variable ch is used to take
the input of the gender as M/m for male and F/f for female. After that the function moves into the
switch case according to the option chosen.
Source Code to Check availability of rooms according to gender:
int gender()
{
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.

10HOSTEL MANAGEMENT SYSTEM
char ch;
printf("Enter gender (M/m or F/f): ");
scanf("%c",&ch);
switch(ch)
{
case 'M':
case 'm':{
printf("Available blocks are A3.\n");
printf("Number of available rooms are: 100\n");
break;
}
case 'F':
case 'f':{
char choice[2];
printf("Available blocks are B1, B3, B4.\n");
printf("Number of available rooms in B1: 100\n");
char ch;
printf("Enter gender (M/m or F/f): ");
scanf("%c",&ch);
switch(ch)
{
case 'M':
case 'm':{
printf("Available blocks are A3.\n");
printf("Number of available rooms are: 100\n");
break;
}
case 'F':
case 'f':{
char choice[2];
printf("Available blocks are B1, B3, B4.\n");
printf("Number of available rooms in B1: 100\n");

11HOSTEL MANAGEMENT SYSTEM
printf("Number of available rooms in B3: 100\n");
printf("Number of available rooms in B4: 100\n");
printf("Please choose your block:");
scanf("%s",choice);
if(choice[0]=='B' && choice[1]=='1')
printf("The rates are: Room=400, Meal=120, GYM=10");
else if(choice[0]=='B' && choice[1]=='3')
printf("The rates are: Room=150, Meal=120, GYM=10");
else if(choice[0]=='B' && choice[1]=='4')
printf("The rates are: Room=100, Meal=120, GYM=10");
else
printf("invalid choice");
break;
printf("Number of available rooms in B3: 100\n");
printf("Number of available rooms in B4: 100\n");
printf("Please choose your block:");
scanf("%s",choice);
if(choice[0]=='B' && choice[1]=='1')
printf("The rates are: Room=400, Meal=120, GYM=10");
else if(choice[0]=='B' && choice[1]=='3')
printf("The rates are: Room=150, Meal=120, GYM=10");
else if(choice[0]=='B' && choice[1]=='4')
printf("The rates are: Room=100, Meal=120, GYM=10");
else
printf("invalid choice");
break;

12HOSTEL MANAGEMENT SYSTEM
}
}
printf("\n");
}
Preview:
}
}
printf("\n");
}
Preview:
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

13HOSTEL MANAGEMENT SYSTEM
Fig 2 & 3. Check availability of rooms according to gender
Total payment to be made
The name of the function is bill(). This function is used to check the total bill based on the user
input. The variables used in this function are tot_week_pay_A3=280, tot_week_pay_B1=530,
tot_week_pay_B3=280, tot_week_pay_B4=230, which are integer type and stores the total
weekly payment for each block and block variable is a character type variable used to take the
input of the block the student will be staying in. Another variable named as stay is an integer
variable and is used to take input from the user for how many weeks they want to stay.
Source Code to check the total payment to be made:
int bill(){
Fig 2 & 3. Check availability of rooms according to gender
Total payment to be made
The name of the function is bill(). This function is used to check the total bill based on the user
input. The variables used in this function are tot_week_pay_A3=280, tot_week_pay_B1=530,
tot_week_pay_B3=280, tot_week_pay_B4=230, which are integer type and stores the total
weekly payment for each block and block variable is a character type variable used to take the
input of the block the student will be staying in. Another variable named as stay is an integer
variable and is used to take input from the user for how many weeks they want to stay.
Source Code to check the total payment to be made:
int bill(){

14HOSTEL MANAGEMENT SYSTEM
int tot_week_pay_A3=280;
int tot_week_pay_B1=530;
int tot_week_pay_B3=280;
int tot_week_pay_B4=230;
char block[2];
int stay;
printf("Enter how many weeks you want to stay:\n");
scanf("%d",&stay);
printf("Enter your block:\n");
scanf("%s",block);
if(block[0]=='A' && block[1]=='3')
printf("Total payment:%d",tot_week_pay_A3*stay);
else if(block[0]=='B' && block[1]=='1')
printf("Total payment:%d",tot_week_pay_B1*stay);
int tot_week_pay_A3=280;
int tot_week_pay_B1=530;
int tot_week_pay_B3=280;
int tot_week_pay_B4=230;
char block[2];
int stay;
printf("Enter how many weeks you want to stay:\n");
scanf("%d",&stay);
printf("Enter your block:\n");
scanf("%s",block);
if(block[0]=='A' && block[1]=='3')
printf("Total payment:%d",tot_week_pay_A3*stay);
else if(block[0]=='B' && block[1]=='1')
printf("Total payment:%d",tot_week_pay_B1*stay);

15HOSTEL MANAGEMENT SYSTEM
else if(block[0]=='B' && block[1]=='3')
printf("Total payment:%d",tot_week_pay_B3*stay);
else if(block[0]=='B' && block[1]=='4')
printf("Total payment:%d",tot_week_pay_B4*stay);
else
printf("Invalid choice.");
}
Preview:
else if(block[0]=='B' && block[1]=='3')
printf("Total payment:%d",tot_week_pay_B3*stay);
else if(block[0]=='B' && block[1]=='4')
printf("Total payment:%d",tot_week_pay_B4*stay);
else
printf("Invalid choice.");
}
Preview:
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.

16HOSTEL MANAGEMENT SYSTEM
Fig 4. Total payment to be made by the student
Check Student details
This function is used to check the student details which are already present in the data file and
the name of this function is see(). A file pointer is used to point to the first data in the file and the
checking process begins after the user inputs the student id or roll number or the name to check
the details.
Source Code to check student details:
int see()
{
Fig 4. Total payment to be made by the student
Check Student details
This function is used to check the student details which are already present in the data file and
the name of this function is see(). A file pointer is used to point to the first data in the file and the
checking process begins after the user inputs the student id or roll number or the name to check
the details.
Source Code to check student details:
int see()
{

17HOSTEL MANAGEMENT SYSTEM
FILE *ptr;
int test=0;
int choice;
ptr=fopen("student_record.dat","r");
printf("Do you want to check by\n1.Roll no\n2.Name\nEnter your choice:");
scanf("%d",&choice);
if (choice==1)
{ printf("\n\nEnter the roll number:");
scanf("%s",check.student_id);
while (fscanf(ptr,"%s %s %d/%d/%d %d %s %d %s %s %d %s\n",add.student_id,
add.name, &add.dob.month, &add.dob.day, &add.dob.year, &add.age, add.city, &add.phone,
add.mail_id, add.father_name, &add.father_phone, add.hostel_name)!=EOF)
{
if(strcmp(add.student_id,check.student_id)==0)
{
test=1;
FILE *ptr;
int test=0;
int choice;
ptr=fopen("student_record.dat","r");
printf("Do you want to check by\n1.Roll no\n2.Name\nEnter your choice:");
scanf("%d",&choice);
if (choice==1)
{ printf("\n\nEnter the roll number:");
scanf("%s",check.student_id);
while (fscanf(ptr,"%s %s %d/%d/%d %d %s %d %s %s %d %s\n",add.student_id,
add.name, &add.dob.month, &add.dob.day, &add.dob.year, &add.age, add.city, &add.phone,
add.mail_id, add.father_name, &add.father_phone, add.hostel_name)!=EOF)
{
if(strcmp(add.student_id,check.student_id)==0)
{
test=1;

18HOSTEL MANAGEMENT SYSTEM
printf("\nROLL NO.:%s\nName:%s \nDOB:%d/%d/%d \nAge:%d \ncity:%s \nPhone
number:%d \nE-Mail id:%s \nFather's name:%s \n Father's Phone No.:%d \nHostel:%s \
n",add.student_id, add.name, add.dob.month, add.dob.day, add.dob.year, add.age, add.city,
add.phone, add.mail_id, add.father_name, add.father_phone, add.hostel_name);
}
}
}
else if (choice==2)
{ printf("\n\nEnter the name:");
scanf("%s",check.name);
while (fscanf(ptr,"%s %s %d/%d/%d %d %s %d %s %s %d %s\n",add.student_id,
add.name, &add.dob.month, &add.dob.day, &add.dob.year, &add.age, add.city, &add.phone,
add.mail_id, add.father_name, &add.father_phone, add.hostel_name)!=EOF)
{
if(strcmp(add.name,check.name)==0)
{
test=1;
printf("\nROLL NO.:%s\nName:%s \nDOB:%d/%d/%d \nAge:%d \ncity:%s \nPhone
number:%d \nE-Mail id:%s \nFather's name:%s \n Father's Phone No.:%d \nHostel:%s \
printf("\nROLL NO.:%s\nName:%s \nDOB:%d/%d/%d \nAge:%d \ncity:%s \nPhone
number:%d \nE-Mail id:%s \nFather's name:%s \n Father's Phone No.:%d \nHostel:%s \
n",add.student_id, add.name, add.dob.month, add.dob.day, add.dob.year, add.age, add.city,
add.phone, add.mail_id, add.father_name, add.father_phone, add.hostel_name);
}
}
}
else if (choice==2)
{ printf("\n\nEnter the name:");
scanf("%s",check.name);
while (fscanf(ptr,"%s %s %d/%d/%d %d %s %d %s %s %d %s\n",add.student_id,
add.name, &add.dob.month, &add.dob.day, &add.dob.year, &add.age, add.city, &add.phone,
add.mail_id, add.father_name, &add.father_phone, add.hostel_name)!=EOF)
{
if(strcmp(add.name,check.name)==0)
{
test=1;
printf("\nROLL NO.:%s\nName:%s \nDOB:%d/%d/%d \nAge:%d \ncity:%s \nPhone
number:%d \nE-Mail id:%s \nFather's name:%s \n Father's Phone No.:%d \nHostel:%s \
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

19HOSTEL MANAGEMENT SYSTEM
n",add.student_id, add.name, add.dob.month, add.dob.day, add.dob.year, add.age, add.city,
add.phone, add.mail_id, add.father_name, add.father_phone, add.hostel_name);
}
}
}
fclose(ptr);
if(test!=1)
printf("\nRecord not found!!\a\a\a");
}
Preview:
n",add.student_id, add.name, add.dob.month, add.dob.day, add.dob.year, add.age, add.city,
add.phone, add.mail_id, add.father_name, add.father_phone, add.hostel_name);
}
}
}
fclose(ptr);
if(test!=1)
printf("\nRecord not found!!\a\a\a");
}
Preview:

20HOSTEL MANAGEMENT SYSTEM
Fig 5. Check student details
Payment options and to cancel the payment in mid-way
This function is used to show the payment options available and to abort the payment in the
midway. The name of this function is payment_facility(). The variables used in this function are
num and choice1 both are integer type.
Source Code for payment options and to cancel the payment in mid-way:
int payment_facility()
{
int num;
int choice1;
Fig 5. Check student details
Payment options and to cancel the payment in mid-way
This function is used to show the payment options available and to abort the payment in the
midway. The name of this function is payment_facility(). The variables used in this function are
num and choice1 both are integer type.
Source Code for payment options and to cancel the payment in mid-way:
int payment_facility()
{
int num;
int choice1;

21HOSTEL MANAGEMENT SYSTEM
printf("Choose 1 for card.\n Choose 2 for cash.\n Choose 3 to abort the payment process.\
n");
printf("Enter your choice:\n");
scanf("%d",&choice1);
switch(choice1)
{
case 1:
printf("\nEnter the card number to proceed:\n");
scanf("%d",&num);
break;
case 2:
printf("\nYour choice was recorded. Please visit the office to pay the due
bill.\n Thank you!\n");
break;
case 3:
printf("\nThe payment was aborted.\n");
break;
default:
printf("Choose 1 for card.\n Choose 2 for cash.\n Choose 3 to abort the payment process.\
n");
printf("Enter your choice:\n");
scanf("%d",&choice1);
switch(choice1)
{
case 1:
printf("\nEnter the card number to proceed:\n");
scanf("%d",&num);
break;
case 2:
printf("\nYour choice was recorded. Please visit the office to pay the due
bill.\n Thank you!\n");
break;
case 3:
printf("\nThe payment was aborted.\n");
break;
default:
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.

22HOSTEL MANAGEMENT SYSTEM
printf("\nInvalid Choice.\n");
}
printf("Your payment is successful.");
printf("\n");
}
Preview:
printf("\nInvalid Choice.\n");
}
printf("Your payment is successful.");
printf("\n");
}
Preview:

23HOSTEL MANAGEMENT SYSTEM

24HOSTEL MANAGEMENT SYSTEM
Fig 6, 7 and 8: Payment options and cancel payment in the mid-way
Fig 6, 7 and 8: Payment options and cancel payment in the mid-way
1 out of 25

Your All-in-One AI-Powered Toolkit for Academic Success.
 +13062052269
info@desklib.com
Available 24*7 on WhatsApp / Email
Unlock your academic potential
© 2024  |  Zucol Services PVT LTD  |  All rights reserved.