Comprehensive Hostel Management System Project using C Language

Verified

Added on  2023/03/31

|18
|1617
|57
Project
AI Summary
This C programming project details the design and implementation of a hostel management system. It includes an introduction to the C programming language, outlining its key features and structure. The project focuses on managing student data, checking room availability based on gender, handling payments, and displaying student details. The program utilizes file handling to store student records and includes functionalities such as selecting payment methods and calculating bills. The project provides flowcharts, pseudo-code, and explanations of ANSI C programming concepts, along with sample outputs demonstrating the program's functionality. The project includes functions for gender-based room availability checks, payment processing, and bill calculation, all implemented using C programming. The document concludes with a summary of the project and references.
Document Page
Running Head: HOSTEL MANAGEMENT SYSTEM
HOSTEL MANAGEMENT SYSTEM
Name of the Student:
Name of the University:
Author Note:
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
1HOSTEL MANAGEMENT SYSTEM
Table of Contents
Introduction and Assumptions.........................................................................................................2
Design of the program.....................................................................................................................3
Explanation of portable ANSI C programming concepts................................................................5
Sample Outputs:...............................................................................................................................7
Conclusion.....................................................................................................................................15
References......................................................................................................................................16
Document Page
2HOSTEL MANAGEMENT SYSTEM
Introduction and Assumptions
The C programming language is a sequential programming language or procedural
language. This programming language was developed between 1969 and 1973 by Dennis
Ritchie. This language was developed mainly for writing operating system (Kanetkar 2016). The
main key features of C programming language are low-level access of memory, set of simple
keywords, and a simple style of writing the code. Many other programming languages like Java,
JavaScript and C++, borrowed the syntax and the features of C language. The basic structure of a
C program includes header files, declaration of the main method, variable declaration, body and
the return statement (Chung et al. 2016).
The C program that we used in this project is based on a hostel management system,
where the student data are inserted and stored in a data file. The other functions of the program
are to show the data stored in the data files when required, checking the availability of rooms
according to gender and make payment for a room or abort the transaction in mid-way.
Assumptions of the C program are there are only 4 blocks available which are A3, B1, B3
and B4 due to the delay in construction of the buildings. The services available are gym and meal
for each block and there are 100 rooms in each block. Another assumption is that there can be
only one input at a time and only one function execution. The data file can store at least 50 data
entries or student records.
Document Page
3HOSTEL MANAGEMENT SYSTEM
Design of the program
Flow Chart
Start
Define structure of student, and date
Read all student information
Check availability of rooms according to gender
Select payment method or abort the payment
Check total bill to be paid based on number of weeks
Check student details by roll number or the
name
Stop
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
4HOSTEL MANAGEMENT SYSTEM
Explanation of the flow chart:
The flowchart provided above shows the different functions used in the program.
Define structure of student, and date- The starting of the program is defining the structures for
the date and the student data.
Read all student information- the next function is to take input from the user about the student
details.
Check availability of rooms according to gender- After that the availability of the rooms are
checked and proceeded accordingly.
Select payment method or abort the payment- In this process the payment method is selected by
the user and the transaction is completed of aborted as per the user.
Check total bill to be paid based on number of weeks- The total bill to be paid based on how
many weeks they want to stay is shown to the user.
Check student details by roll number or the name- This process is used to check the student
details. The user can search for the student details either by the roll number or the name.
Pseudo Code to Check availability of rooms according to gender:
INPUT gender (M/m or F/f)
If gender entered is M/m
Switch to case ‘m’ or ‘M’
Print the available blocks
If gender entered is F/f
Document Page
5HOSTEL MANAGEMENT SYSTEM
Switch to case ‘f’ or ‘F’
Display the available blocks
Explanation of the pseudo code
The pseudo code provided above is to check the availability of rooms according to the
gender. The input of the gender is taken from the user and according to that the program gets
inside a switch case. If the user input is M/m which indicates the user is looking for available
rooms for a male student the program enters into the ‘m’ case and if the user input is F/f then the
program uses the ‘f’ case.
Explanation of portable ANSI C programming concepts
FILE *ptr- used in the program indicates file pointer named as ptr.
printf() used in the program is a library function that is used to display a output on the screen.
#include in #include<stdio.h> and other header files indicated these are preprocessors and the
stdio.h and other .h extension files indicate that these are header files and each header file is
predefined with some set of library functions. For example, printf() is defined in stdio.h so to
access printf() function inclusion of stdio.h header file is important.
scanf() also defined in stdio.h is used to take and store input by the user.
The main() function is the starting point for any C program and the execution of the code begins
from this main function. The curly braces {} are used to define the body of the main function.
ptr=fopen("student_record.dat","r")- In this line of the code the ptr is the file ointer and fopen is
the function used to open a file named as student_record which is a .dat of data file and the ‘r’
indicated that the file is opened in read only mode.
Document Page
6HOSTEL MANAGEMENT SYSTEM
%d, %c, %s- these are the data identifiers used in the program.
Test specification table
Function Time
complexity
Input taken Output Result
gender() O(2) m/M Shows the
printed message
as “Available
blocks are A3.”
The function
executes
properly.
new_entry() O(n) Student details If the student
roll no already
exist then shows
the message
“Student already
exist.” If the
input student id
is new the
program takes
all the input.
This function
executes
properly.
bill() O(n) Choice of block
by the student
After the block
is entered by the
student, the total
payment to be
made is
The function
executes
properly.
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
7HOSTEL MANAGEMENT SYSTEM
calculated and
displayed.
see() O(2n) Takes input
from the user as
to how they
want to search
the student
details by
student Id or the
name.
After the student
enters their
choices the
student details is
visible on the
screen.
The function
executes
properly.
payment_facility(
)
O(3) Enters the
choice and
according to that
the program
enters the switch
case.
If choice is 1
then the
payment method
is card and to
input the card
number is
displayed.
The function
runs properly.
Sample Outputs:
Source code:
int payment_facility()
{
Document Page
8HOSTEL MANAGEMENT SYSTEM
int num;
int choice1;
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");
Document Page
9HOSTEL MANAGEMENT SYSTEM
break;
default:
printf("\nInvalid Choice.\n");
}
printf("Your payment is successful.");
printf("\n");
}
Explanation of the code and output:
The source code provide above is for the payment method to be used or to abort the payment.
After the execution the menu opens and the user is asked to enter which payment method they
want to choose ‘1’ is for card, ‘2’ is for cash and ‘3’ to abort the payment. After the user entered
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
10HOSTEL MANAGEMENT SYSTEM
‘1’ then they are asked to enter their card number to proceed. After they enter their card number
a message is show that their payment is successful.
Source code:
int bill(){
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')
Document Page
11HOSTEL MANAGEMENT SYSTEM
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);
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:
chevron_up_icon
1 out of 18
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]