0% found this document useful (0 votes)
27 views100 pages

Finalised C Project

This document describes a student project to create an online canteen management system using C programming. The system will allow customers to order meals and view bills based on the current time. It covers concepts learned in class and aims to provide a practical learning experience for the students.

Uploaded by

Tiger Shroff
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views100 pages

Finalised C Project

This document describes a student project to create an online canteen management system using C programming. The system will allow customers to order meals and view bills based on the current time. It covers concepts learned in class and aims to provide a practical learning experience for the students.

Uploaded by

Tiger Shroff
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 100

TRIBHUVAN UNIVERSITY

INSTITUTE OF ENGINEERING
PULCHOWK CAMPUS

PROJECT ON
“Canteen Management System
(PULCHOWK E-CANTEEN MANAGEMENT PORTAL)”

A course Project Submitted to the Department of Electronics and Computer Engineering


in partial fulfilment of the requirements for the Practical course on Computer
Programming [CT 401]

Submitted to:
Department of Electronics and Computer Engineering, Pulchowk Campus
Institute of Engineering,
Tribhuvan University Lalitpur, Nepal
Shrawan 2078

Submitted by:
Abhinna Rimal (078BCE012)
Agrim Paudel (078BCE016)
Ayush Aryal (078BCE031)
Bibek Subedi (078BCE035)
PULCHOWK E-CANTEEN MANAGEMENT PORTAL

2
ABSTRACT

In this age of internet and modern technology, we still face the long awaited
queues in the canteen of our campus. Developments have been a long time due in
the canteen management process. The manual ordering makes the process tedious
and time consuming. Therefore, to eliminate these kinds of manual
time-consuming processes, our team has come up with an effective solution for this
hurdle, an online canteen management system, “PULCHOWK E-CANTEEN
MANAGEMENT PORTAL”, which allows the customer to order all 3 meals
according to the time, with ease and collect the order with ease in the system.

The main objective of this project is to create a system that manages the
order entered by the user with his/her roll number and displays the bill with billing
amount for all three types of meals available in the canteen using C programming
language. C is a general-purpose computer programming language. It was created
in the 1970s by Dennis Ritchie, and remains very widely used and influential. By
design, C's features cleanly reflect the capabilities of the targeted CPUs. It has
found lasting use in operating systems, device drivers, protocol stacks, though
decreasingly for application software, and is common in computer architectures
that range from the largest supercomputers to the smallest microcontrollers and
embedded systems.

The project covers almost all the fundamental aspects of C-programming


language. We will be utilising almost every concept and technique that we have
acquired knowledge about in the first semester classes and also introducing some
new concepts, assisted by the internet.

3
ACKNOWLEDGEMENT

“Knowledge is in the end based on acknowledgement.”


-Ludwig Wittgenstein

We would like to express our special gratitudes to our computer


programming teacher, Mr. Santosh Giri, who presented us with this wonderful
opportunity to showcase our logical ideas and talents in the form of a
C-programming project development. We would also like to thank him for the
valuable lessons, concepts, and techniques he provided us with in the classroom for
use to implement them and make the program as effective as it could be.We would
also like to place apperception to all the respondents and group members whose
responses and coordination were of utmost importance for the completion of this
project.

Finally, we would like to thank our parents, classmates and respondents who
helped us to collect the information in the limited time frame to complete the
project.

4
TABLE OF CONTENTS

Chapter 1: INTRODUCTION 6-7


1.1 Background and Problem Statements
1.2 Objectives
1.3 Features
1.4 Limitations

Chapter 2: PROBLEM ANALYSIS 8


2.1 Understanding the Problem
2.2 Feasibility
2.3 Input requirements
2.4 Processing requirements
2.5 Output requirements

Chapter 3: REVIEW OF THE C-PROGRAMMING LANGUAGE 9-22

Chapter 4: DESIGN 23-58


4.1 Algorithms
4.2 Flowcharts

Chapter 5: PROGRAMMING AND DEPLOYMENT 59-67


5.1 Implementation
5.2 Testing
5.3 Coding

Chapter 6: RESULT AND DISCUSSION 68-79

Chapter 7: CONCLUSION 80

REFERENCES 81

APPENDIX 82-100

5
Chapter 1:
INTRODUCTION
Our project, “PULCHOWK E-CANTEEN MANAGEMENT PORTAL” is
based on a very popular high level programming language, C-programming
language, which is a structured and procedure oriented programming language
designed by Dennis Ritchie. The program comprises the predefined syntaxes that
are present in the C-library, which can be accessed by the use of English keywords.
This program is based on the system time, which is automatically taken by the
program on time of execution and thus on the basis of that time, displays the meal
menu of that time in the day or requests the customers to come back at the opening
time. He/She, on the opening time, can enter his/her roll number and then proceed
to order the food items and drinks from the menu, and the program returns the bill
of the ordered items with the total sum to be paid by the customer. For
incorporations of the above mentioned program, we have used input/output
statements, control structures, user defined functions, arrays, strings, pointers,
structures and file handling concepts. We also have included the “time.h” header
file to retrieve the system time and use it effectively in the program.

1.1 Background and Problem Statements:


We as students of the Civil Engineering group were taught about the
fundamental concepts of programming in high level language as a way of
improving our skills in logical reasoning, application of technical knowledge, and
quantitative problem solving effectively and efficiently. Thus, we were assigned to
prepare a project in C language in order to have a basic practical knowledge about
C-programming. This project is a part of the subject Computer Programming-I first
year, first part(semester) of the Civil Engineering Course. Analysing the current
status of canteen in the campus, we came up with an idea to make a program based
on the canteen management system.

After the formation of the group, we had a small inquisitive session about the
types of logics to be implemented in the program. This led us to the conclusion of
making a program that retrieves the time information from the system and
automatically displays the available menu from the available meal in the program

6
runtime. We then discussed the different modules to be implemented and after this,
we divided the work into almost four equal parts and decided to work on the
individual tasks. We used the resources provided by our teacher, Mr. Santosh Giri,
and collected the additional resources from reference books and different websites,
along with the guidance from seniors. The coding process was followed by the
compilation process and testing was done several times to reduce the errors of the
program. The reliability of the program was secured and then the report was
documented. The hard-work and dedication of the team members finally led to the
successful completion of the project.

1.2 Objectives:
I. To acquire the ideas and implement the concepts of functions, arrays,
pointers, structures and file handling procedures.
II. To develop a mini-database system with help of C.
III. To learn about the different header files and the library functions stored in
them, and to implement them effectively in the program.
IV. To be able to develop valiant team-work skills with division of tasks.
V. To be able to solve a complex problem with the help of a simplification
process in C.

1.3 Features:
The program contains the following features to make it more realistic and
efficient:
I. It uses the system time during execution and displays either the breakfast,
lunch or dinner menu according to the time, and displays closed on the
closing time and requests the user to return later.
II. The records are stored in “record.txt”, which can be accessed by the admin
to see the total amounts of orders and account it respectively.
III. It allows the customer to pick different types of meals during the same
transaction, with the option to add drinks as well.
1.4 Limitations:
I. The program doesn’t allow the customer to just buy drinks from the menu
automatically, unless you breach the system.
II. The program uses some library functions, which were not discussed in the
classroom.

7
Chapter 2:
PROBLEM ANALYSIS
2.1 Understanding the Problem:
Our team , in our second discussion session, had a brainstorm about what type of
management database would be suitable for the efficiency of the program. We
came up with the idea of integrating the system time with the help of the “time.h”
header file and choosing different versions of the display system on the basis of the
time given by the system during execution. To make the display more
user-friendly, we also came up with the idea of using file handling in ASCII art to
make the program execution look better.

2.2 Feasibility:
The project required fundamental skills in C programming language and collective
team effort with the blend of proper logics. Time management was very crucial
since we also could not miss any assignments or regular classes, with assessments
of many subjects incoming. Integration and compilation of individual work also
had to be done to complete the actual project.

2.3 Input requirements:


Input section consists of the source of input data, which is very crucial to display
the output. The user(customer) has to enter his/her roll number and the program
welcomes the customer to the menu. The customer can place his/her order from the
menu. The program was made in such a way that the customer has to input the
choice again in case of invalidation of the choices presented by the menu.

2.4 Processing requirements:


A device running on a 32-bit OS (or more) is required for the processing. The data
had to be processed in such a way that even on entering unexpected or unusual
input, the system would still not crash.

2.5 Output requirements:


Output section consists of data to be presented in the console screen. The unusual
choices were not allowed by the program to be input through messages displayed,
and the billing information was to be displayed at the end of the order for the users.

8
Chapter 3:
REVIEW OF THE C-PROGRAMMING LANGUAGE
C is a procedural programming language. It was initially developed by Dennis
Ritchie as a system programming language to write operating systems. The main
features of C language include low-level access to memory, simple set of
keywords, and clean style. These features make C language suitable for system
programming like operating system or compiler development. C is a function
oriented additional task including input and output, graphics, maths computation
and access to peripheral devices are placed as library functions.

3.1 Structure of a C-program:

Section Description

Documentation Consists of the description of the program, programmer's


name, and creation date. These are generally written in the
form of comments.

Link All header files are included in this section which contains
different functions from the libraries. A copy of these
header files is inserted into your code before compilation.

Definition Includes preprocessor directive, which contains symbolic


constants. E.g.: #define allows us to use constants in our
code. It replaces all the constants with its value in the code.

Global Declaration Includes declaration of global variables, function


declarations, static global variables, and functions.

Main() Function For every C program, the execution starts from the main()
function. It is mandatory to include a main() function in
every C program.

9
Subprograms Includes all user-defined functions (functions the user
provides). They can contain the inbuilt functions, and the
function definitions declared in the Global Declaration
section. These are called in the main() function.
The structure can be shown by the following outlines:
Comments/Documentation section
Global variable declaration
main( )
{ local variable declaration
…………………………
statements
………………….
}
function1( )
{ body
…………….
}
function2( ) {
body
……………
}
3.2 Input and Output Functions
Input refers to the process of feeding data into the program.When data comes from
an external location to the program, it is moved to RAM where the program can
access it and that external data is known as input. Output refers to sending data out
of the program or simply sending data to the location out of the program memory.
There are two types of input/output functions in C:
a. Unformatted Input/Output Functions:
Unformatted console input/output functions are used to read a single input
from the user at the console and it also allows us to display the value in the
output to the user at the console. Following are the different types of
unformatted input/output functions used in C.

10
Reads a single character from the user at the console, without
getch() echoing it. Syntax:
character_variable=getch();

Reads a single character from the user at the console, and


getche() echoing it.Syntax: character_variable=getche();

getchar() Reads a single character from the user at the console, and
echoing it, but needs an Enter key to be pressed at the end.
Syntax: character_variable=getchar();
Reads a single string entered by the user at the console.Syntax:
gets() gets(string_variable);
Displays a single string's value at the console.Syntax:
puts() puts(string_variable);
putchar() Displays a single character value at the console. Syntax:
putchar(character_variable or variable_name);

b. Formatted Input/Output Functions:


I. scanf() function helps to read the file or input which we provide and in
scanf() function we use format specifiers like %c, %d, etc to detect the data
type of variable which we give as input.
Syntax: scanf(“format_string”, &var1, &var2, &var3, …, &varN);
II. printf() is a formatted output function which is used to display some
information on standard output units. It is defined in the standard header file
“stdio.h”.
Syntax: printf("String"); or printf(“format_string”, var1, var2, var3, …,
varN);
Some format specifiers: %c(char,1 byte), %d(int,2 bytes), %ld(long,4 bytes),
%f(float, 4 bytes), %lf(double, 8 bytes), %Lf(long double, 10 bytes).
3.3 Control Structures:
The control statements used in the C language help a user to specify a
program control’s flow. In simpler words, the control statements help users specify
the order of execution of the instructions present in a program. These make it

11
possible for the program to make certain decisions, perform various tasks
repeatedly, or even jump from any one section of the code to a different section.
A. Sequential Structure: The program executes instruction in sequential order
contained in the source code.
B. Branching Structure(Selective Structure): In a realistic C program, it
may require a logical test to be carried out at some particular point within
the program and depending on the outcome of the logical test, several
possible actions will be carried out, this is known as branching or
conditional branching statements.
I. Simple if-statement: If statement is one of the powerful conditional
statements in C language. The If statement is always used with a condition.
Syntax:
if (Condition)
{
Statements;
}
II. if-else Statement: if-else statement first tests a condition then it allows us
to take two possible actions, one is when condition is TRUE, and the other is
when condition is FALSE. Syntax:
if (Condition)
{
Statement1;
}
else
{
Statement2;
}
III. if-else-if Statement (Ladder): In programming, if-else-if statement is
also known as if-else-if ladder. It is used when there are more than two
possible actions based on different conditions. Syntax:
if (Condition1)
{
Statement1;
}
else if(Condition2)

12
{
Statement2;
}
.
.
.
else if(ConditionN)
{
StatementN;
}
else
{
Default_Statement;
}
IV. Switch case: A switch statement is used for multiple way selections that
will branch into different code segments based on the value of a variable or
expression. This expression or variable must be of integer or character data
type. Syntax:
switch (expression)
{
case value1:
code segment1;
break;
case value2:
code segment2;
break;
.
.
.
case valueN:
code segmentN;
break;
default:
default code segment;
}

13
C. Iteration Structure: In C, the program may require that a group of
statements be executed repeatedly, until some logical condition has been
satisfied this is known as looping or iteration. Sometimes the required
number of repetition is known in advance; and sometimes statements are
executed until the logical condition becomes true.
I. For loop: The for loop is the most commonly used looping statement.
It is a pre-tested loop and it is used when the number of repetitions
(iterations) are known in advance. The syntax of the loop consists of
three parts: control variable initialization, condition and control
variable update. These three parts are separated by semicolons.
Syntax:
for (control_variable_initialization;condition;control_variable_update)
{
statement(s); //body of loop
}
II. While loop: While loop is a pre-tested loop, it tests the expression
before every repetition of the loop body. Statements within the body
of the loop are executed until some condition is satisfied. The while
loop looks like a simplified version of the for loop. In its syntax it
consists of condition but not control variable initialization and control
variable update. However, loop control variables must be initialised
before condition is checked and loop body must also contain control
variable update to avoid infinite loop.
Syntax:
control_variable_initialization;
while (condition)
{
statement(s);
control_variable_update;
}
III. Do-while loop: do-while loop is post-tested loop. The do-while loop
is very similar to the while loop except that the condition is checked at
the end of the loop body. This guarantees that the loop is executed at
least once before terminating.
Syntax:

14
control_variable_initialization;
do
{
statement(s);
control_variable_update;

} while (condition);
D. Jumping functions: Jump statements in C/C++ are a type of Control
Statements in C/C++ used to interrupt the normal flow of the program. It makes the
program jump to another section of the program unconditionally when
encountered. It can also be used to terminate any loop.
I. Goto statement: The goto statement is also known as the jump control
statement, it is used to transfer the control of the program from one block to
another. The goto keyword is used when declaring the goto statement.
Syntax:
goto labelname;
Labelname;
II. Break statement: When a break statement is encountered inside a loop, the
loop is immediately terminated and the program control resumes at the next
statement following the loop. It can be used to terminate a case in the switch
statement.
Syntax:
break;
III. Continue statement: The continue statement skips the current iteration of
the loop and continues with the next iteration.
Syntax:
continue;
3.4 Functions
A function is a set of statements that take inputs, do some specific computation and
produce output. The idea is to put some commonly or repeatedly done tasks
together and make a function so that instead of writing the same code again and
again for different inputs, we can call the function.
Library functions: C Standard library functions or simply C Library functions are
inbuilt functions in C programming. The prototype and data definitions of these
functions are present in their respective header files. To use these functions we

15
need to include the header file in our program. Examples include:
printf(),scanf(),etc.
User defined Functions: A user defined function is a sub-program which groups a
number of program statements into a single unit for accomplishing a specific task
and assigns it a name.
a. Function Prototype or Function Declaration: Like any variable in a C
program it is necessary to declare a function before its use. Declaration
of function informs the compiler about the existence of function and it
will be defined and used later. This declaration of function is also known
as function prototype.
Syntax: return_type function_name(type1 var1, ... , typeN varN);
b. Function Definition: In C programming, a user defined function must be
defined before it is called or used in the program. Function definition
consists of all the code required for its implementation.
Syntax:
return_type function_name(type1 var1, ... ,typeN varN)
{
statement1;
statement2;
.
.
.
statementN;

return statement;
}
c. Function Call: After declaring and defining user defined function, it can
be used when needed. Generally, a user defined function is used by
calling or invoking it by passing required data, if necessary, for its
functioning. Using function by providing data required for its functioning
is known as function call.
Syntax: function_name( var1, var2, ...... , varN );
Types of functions include the functions with
● Return value and arguments
● No return value but arguments

16
● Return value but no arguments
● No return value and arguments
In our program, we have used three types of above functions, excluding the first
type.
3.5 Arrays and Strings
Array: It is a group of variables of similar data types referred to by a single
element. Its elements are stored in a contiguous memory location. The size of the
array should be mentioned while declaring it. Array elements are always counted
from zero (0) onward. Array elements can be accessed using the position of the
element in the array. The array can have one or more dimensions.
Array Declaration:
Syntax: dataType arrayName[arraySize];
For example,
float mark[5];
Here, we declared an array, mark, of floating-point type. And its size is 5.
Meaning, it can hold 5 floating-point values.
Accessing Array Elements:
Array elements are accessed by using an integer index. Array index starts with 0
and goes till the size of the array minus 1.
The name of the array is also a pointer to the first element of the array.
Array Input/Output:
Here's how you can take input from the user and store it in an array element.
// take input and store it in the 3rd element
​scanf("%d", &mark[2]);
// take input and store it in the ith element
scanf("%d", &mark[i-1]);

Here's how you can print an individual element of an array.


// print the first element of the array
printf("%d", mark[0]);
// print the third element of the array
printf("%d", mark[2]);
// print ith element of the array
printf("%d", mark[i-1]);

17
Strings: A string is a sequence of characters terminated with a null character \0.
For example:
char c[] = "c string";
When the compiler encounters a sequence of characters enclosed in the double
quotation marks, it appends a null character ‘\0’ at the end by default.
3.6 Structures
A struct (or structure) is a collection of variables (can be of different types) under a
single name. Structure is also known as record. A structure is a convenient way of
grouping several data items together. In the C programming language, using
structure, we can create and use data types other than the basic or fundamental data
types. These are known as user defined data types. Structures are created by using
the struct keyword and can be defined as user defined data types.
Declaration of Structure & Structure Variables:
Syntax:
struct structure_name
{
data_type member1;
data_type member2;
data_type member3;
.
.
.
data_type memberN;
};
Syntax for Creating Structure Variables After Declaring Structure:
struct structure_name var1, var2, var3, …., varN;
General syntax for declaring structure variables at the time of structure
declaration :
struct structure_name
{
data_type member1;
data_type member2;
data_type member3;
.
.

18
.
data_type memberN;

} var1, var2, var3, …., varN;


Accessing Structure Elements:
Individual structure elements can be accessed by using the . (dot) operator along
with structure variables. The general syntax for accessing structure variables is:
structure_variable.member_name
Example:
struct student
{
char name[30];
int roll;
float marks;
};
Initialisation:
struct student s1 = {“Parijat”, 13, 80.5};
Then, individual value can be obtained as:
s1.name gives “Parijat”
s1.roll gives 13
s1.marks gives 80.5
3.7 File Handling Operations:
We frequently use files for storing information which can be processed by our
programs. Such files are called data files. A file is a bunch of bytes stored on some
storage device. Most of the application program processes a large volume of data
which is permanently stored in data files. In order to store information permanently
and retrieve it, we need to use data files. While developing software essential data
is stored in data files or databases because data communication between the
console unit and program is tedious and error-prone.
FILE Pointer:
As we know, we can have many files on our disk. While dealing with files, in our
program, we need to specify which files we wish to use. In c programming, we use
a new data type called file pointer to communicate with files. Every file we open
has its own file pointer variable. When we wish to read from a file or write to a
file, we need to specify the file pointer variable.

19
Syntax:
FILE *file_pointer1, *file_pointer2, *file_pointer3, ..., *file_pointerN;
Opening a file:
The file pointer can be used to open and close the file as follows:
file_pointer = fopen(“path_string_for_file”, “mode_string”);
Different modes of File Operations:-
Files can be opened in different modes depending upon the file operation(s) we
wish to perform. Following are the different mode strings are used in the project
are as follows:
a. write mode(“w”)
b. read mode (“r”)
c. append mode (“a”)
Closing a file:
A file can be closed by using fclose() function using the syntax as follows:
fclose(file_pointer);
where, file_pointer is a file pointer to an opened file.
fgetc():
fgetc() is used to obtain input from a file single character at a time. This function
returns the ASCII code of the character read by the function. It returns the
character present at the position indicated by the file pointer. After reading the
character, the file pointer is advanced to the next character. If the pointer is at the
end of the file or if an error occurs, the EOF file is returned by this function.
Syntax:
character_variable = fgetc(FILE *pointer);
fputc():
fputc() is used to write a single character at a time to a given file. It writes the
given character at the position denoted by the file pointer and then advances the
file pointer. This function returns the character that is written in case of successful
write operation else in case of error EOF is returned.
Syntax:
fputc(character_variable, FILE*pointer);
fputs():
It writes a string to the specified stream up to but not including the null character.
Syntax:
fputs(string_variable or “string data”,FILE*pointer);

20
3.8 C – time.h library functions

Functions Description

setdate() This function used to modify the system date

getdate() This function is used to get the CPU time

clock() This function is used to get current system time

time() This function is used to get current system time as structure

This function is used to get the difference between two given


difftime()
times

strftime() This function is used to modify the actual time format

mktime() This function interprets tm structure as calendar time

This function shares the tm structure that contains date and time
localtime()
informations

This function shares the tm structure that contains date and time
gmtime()
informations

21
This function is used to return string that contains date and time
ctime()
informations

Tm structure contents are interpreted by this function as calendar


asctime()
time. This time is converted into string.

Getting hour as integer from the system:


The following code was used in the program abstracted from the time functions
using website[1].
time_t now;
struct tm *now_tm;
int hour;

now = time(NULL);
now_tm = localtime(&now);
hour = now_tm->tm_hour;

22
Chapter 4:
DESIGN
4.1 Algorithm
Algorithm is a step-by-step procedure, which defines a set of instructions to be
executed in a certain order to get the desired output. Algorithms are generally
created independent of underlying languages, i.e. an algorithm can be implemented
in more than one programming language. An algorithm should have the following
characteristics −
● Unambiguous − Algorithms should be clear and unambiguous. Each of its
steps (or phases), and their inputs/outputs should be clear and must lead to
only one meaning.

● Input − An algorithm should have 0 or more well-defined inputs.

● Output − An algorithm should have 1 or more well-defined outputs, and


should match the desired output.

● Finiteness − Algorithms must terminate after a finite number of steps.

● Feasibility − Should be feasible with the available resources.

● Independent − An algorithm should have step-by-step directions, which


should be independent of any programming code.

ALGORITHM FOR THE PROGRAM:

1. main() function:
Step 1: Start.
Step 2: Open file “order.txt” in writing mode.
Step 3: Open file “record.txt” in append mode.
Step 4: Assign value of hour of the system time to a variable(hr) via the
sub-function ‘int timer()’
Step 5: Is 8<hr<=11?
If yes:
Call breakfast(0);
If no:

23
Goto step 6.
Step 6: Is 11<hr<=17?
If yes:
Call lunch();
If no:
Goto step 7.
Step 7: Is 17<hr<22?
If yes:
Call dinner(0);
If no:
Goto step 8.
Step 8: Is 6<=hr<=8?
If yes:
Call nasta(0);
If no:
Call logo(“closed.txt”);
Call admin();
Step 8: Pause the system.
Step 9:Stop.

2. void breakfast(int sum) function: (non return type function using one
argument to calculate the billing amount)
Step 1: Start.
Step 2: Declare variable for roll number.
Step 3: Clear screen
Step 4: Display time and logo using respective functions and other necessary info.
Step 5: Input roll number.
Step 6: Declare a string array and store roll number as a string in it using
convert(char [],int) function.
Step 7: Write roll number and billing information titles in the “order.txt” file.
Step 8: Clear screen
Step 9: Display time and logo using respective functions
Step 10: Display the menu for breakfast
Step 11: Ask the user to make a choice among the available options.

24
Step 12: Is the user’s choice among the available options?
If yes:
Goto step 13.
If no:
Ask the user to make the choice again.
Goto step 11.
Step 13: Ask the user to enter the quantity of the item he/she has chosen.
Step 14: As the user choice matches with one of the available options, perform the
following tasks for the matched option.
14.1: calculate the sum as:
sum=sum+(price of item chosen)*quantity;
14.2: Write the name of item chosen, it’s rate and quantity into the
“order.txt” file.
Step 15: Display options: 1. To order more 2. Order drinks 3. Get the bill
Step 16: Ask the user to make a choice.
Step 17: Is choice==1?
If yes:
Goto Step 8.
If no:
Goto step 18.
Step 18: Is choice==2?
If yes:
Call drinks(sum);
If no:
Goto step 19.
Step 19: Is choice==3?
If yes:
Call total(sum);
If no:
Ask the user to make a valid choice.
Goto step 16.
Step 20: Stop.

3. void lunch() function:(no return type function with no argument)

25
Step 1: Start.
Step 2: Declare variable for roll number
Step 3: Clear screen
Step 4: Display time and logo using respective functions and other necessary info
Step 5: Input roll number
Step 6: Declare a string array and store roll number as a string in it using
convert(char [],int) function
Step 7: Write roll number and billing information titles in the “order.txt” file.
Step 8: Clear screen
Step 9: Display time and logo using respective functions
Step 10: Display 1. Veg 2. Non veg
Step 11: Ask the user to choose the menu they prefer.
Step 12: Is choice==1?
If yes:
Call veg(0);
If no:
Goto step 13.
Step 13: Is choice==2?
If yes:
Call nonveg(0);
If no:
Ask the user to make a valid choice.
Goto step 11.
Step 14: Stop.

4. void nonveg(int sum):(non return type function using one argument to calculate
billing amount)
Step 1: Start.
Step 2: Clear Screen
Step 3: Display logo and time using respective functions.
Step 4: Display the non veg menu.
Step 5: Ask the user to make a choice.
Step 6: Is the user’s choice among the available options?
If yes:
Goto step 7.

26
If no:
Ask the user to make the choice again.
Goto step 5.
Step 7: Ask the user to enter the quantity of the item he/she has chosen.
Step 8: As the user choice matches with one of the available options, perform the
following tasks for the matched option.
8.1: calculate the sum as:
sum=sum+(price of item chosen)*quantity;
8.2: Write the name of the item chosen, its rate and quantity into the
“order.txt” file.
Step 9: Display options: 1. To order more 2. Order from veg menu 3. To order
drinks 4. To get the bill
Step 10: Ask the user to make a choice.
Step 11: Is choice==1?
If yes:
Goto step 2;
If no:
Goto step 12.
Step 12: Is choice==2?
If yes:
Call veg(sum);
If no:
Goto step 13.
Step 13: Is choice==3?
If yes:
Call drinks(sum);
If no:
Goto step 14.
Step 14: Is choice==4?
If yes:
Call total(sum);
If no:
Ask the user to make a valid choice.
Goto step 10.
Step 15: Stop.

27
5. void veg(int sum):(non return type function using one argument to calculate
billing amount)
Step 1: Start.
Step 2: Clear Screen
Step 3: Display logo and time using respective functions.
Step 4: Display the veg menu
Step 5: Ask the user to make a choice.
Step 6: Is the user’s choice among the available options?
If yes:
Goto step 7.
If no:
Ask the user to make the choice again.
Goto step 5.
Step 7: Ask the user to enter the quantity of the item he/she has chosen.
Step 8: As the user choice matches with one of the available options, perform the
following tasks for the matched option.
8.1: calculate the sum as:
sum=sum+(price of item chosen)*quantity;
8.2: Write the name of the item chosen, its rate and quantity into the
“order.txt” file.
Step 9: Display options: 1. To order more 2. Order from non veg menu 3. To order
drinks 4. To get the bill
Step 10: Ask the user to make a choice.
Step 11: Is choice==1?
If yes:
Goto step 2;
If no:
Goto step 12.
Step 12: Is choice==2?
If yes:
Call nonveg(sum);
If no:
Goto step 13.

28
Step 13: Is choice==3?
If yes:
Call drinks(sum);
If no:
Goto step 14.
Step 14: Is choice==4?
If yes:
Call total(sum);
If no:
Ask the user to make a valid choice.
Goto step 10.
Step 15: Stop.

6. void dinner(int sum) function: (non return type function using one argument
to calculate the billing amount)
Step 1: Start.
Step 2: Declare variable for roll number.
Step 3: Clear screen
Step 4: Display time and logo using respective functions and other necessary info.
Step 5: Input roll number.
Step 6: Declare a string array and store roll number as a string in it using
convert(char [],int) function.
Step 7: Write roll number and billing information titles in the “order.txt” file.
Step 8: Clear screen
Step 9: Display time and logo using respective functions.
Step 10: Display the menu for dinner.
Step 11: Ask the user to make a choice among the available options.
Step 12: Is the user’s choice among the available options?
If yes:
Goto step 13.
If no:
Ask the user to make the choice again.
Goto step 11.

29
Step 13: Ask the user to enter the quantity of the item he/she has chosen.
Step 14: As the user choice matches with one of the available options, perform the
following tasks for the matched option.
14.1: calculate the sum as:
sum=sum+(price of item chosen)*quantity;
14.2: Write the name of the item chosen, its rate and quantity into the
“order.txt” file.
Step 15: Display options: 1. To order more 2. Order drinks 3. Get the bill
Step 16: Ask the user to make a choice
Step 17: Is choice==1?
If yes:
Goto Step 8.
If no:
Goto step 18.
Step 18: Is choice==2?
If yes:
Call drinks(sum);
If no:
Goto step 19.
Step 19: Is choice==3?
If yes:
Call total(sum);
If no:
Ask the user to make a valid choice.
Goto step 16.
Step 20: Stop.

7. void drinks(int sum): (no return type function with one argument to find the
billing amount)
Step 1: Start
Step 2: Clear Screen
Step 3: Display logo and time using respective functions.
Step 4: Display the drinks menu.
Step 5: Ask the user to make a choice.

30
Step 6: Is the user’s choice among the available options?
If yes:
Goto step 7.
If no:
Ask the user to make the choice again.
Goto step 5.
Step 7: Ask the user to enter the quantity of the item he/she has chosen.
Step 8: As the user choice matches with one of the available options, perform the
following tasks for the matched option.
8.1: calculate the sum as:
sum=sum+(price of item chosen)*quantity;
8.2: Write the name of the item chosen, its rate and quantity into the
“order.txt” file.
Step 9: Get the value of hour of system time via the timer() function and assign it
to a variable(hr).
Step 10: Is 11<=hr<=17?
If yes:
Goto step 11.
If no:
Goto step 18.
Step 11:Display options: 1. To order more 2. Order from non veg menu 3. To order
from veg menu 4.To get the bill
Step 12: Ask the user to make a choice.
Step 13: Is choice==1?
If yes:
Goto step 2.
If no:
Goto step 14.
Step 14: Is choice==2?
If yes:
Call nonveg(sum);
If no:
Goto step 15.
Step 15: Is choice==3?
If yes:

31
Call veg(sum);
If no:
Goto step 16.
Step 16: Is choice==4?
If yes:
Call total(sum);
If no:
Ask the user to make a valid choice.
Goto step 12.
Step 17: Goto step 22.
Step 18: Display 1. To order more 2. To get the bill
Step 19: Ask the user to make a choice
Step 20: Is choice==1?
If yes:
Goto step 2.
If no:
Goto step 21.
Step 21: Is choice==2?
If yes:
Call total(sum);
If no:
Ask the user to make a valid choice.
Goto step 19.
Step 22: Stop.

8. void total(int sum) function: (non return type with one argument to get the
billing amount)
Step 1: Start.
Step 2: Clear screen
Step 3: Convert the value of sum into string using function convert(char [], int) and
store it in an array.
Step 4: Write total into the file “order.txt”.
Step 5: Close the “order.txt” file.
Step 6: Call record();
Step 7: Stop.

32
9. void convert(char a[],int n): (non return type function working on pass by
reference to change integers into strings)
Step 1: Start.
Step 2: Declare variables i=0, rem, rn=0, count=0
Step 3: Is (n>0)?
If yes:
Perform the following operations:
rem=n%10;
rn=rn*10+rem;
n=n/10;
count++;
Goto step 3.
If no:
Goto step 4.
Step 4: Is i<count?
If yes:
Perform the following operations:
rem=rn%10;
a[i]=(char)(rem+48);
rn=rn/10;
Goto step 4.
If no:
Assign a[i]=’\0’
Goto step 5.
Step 5: Stop.

10. void record(): (no return type function with no arguments)


Step 1: Start.
Step 2: Declare char type variable ch.
Step 3: Open file “order.txt” in reading mode.
Step 4: Read a character from the file “order.txt’.
Step 5: Is the read character!=EOF?
If yes:
Display the read character.

33
Write the character into the file “record.txt”.
If no:
Goto step 6.
Step 6: Close files “order.txt” and “record.txt”.
Step 7: Hold the console screen using system(“pause”).
Step 8: Stop.

11. void logo(char a[]): (non return type function with an argument to pass the
name of the file to be read)
Step 1:Start.
Step 2: Open the file passed into the function in reading mode.
Step 3: Read a character from the file passed into the function.
Step 4: Is the read character!=EOF?
If yes:
Display the character.
If no:
Goto step 5.
Step 5: Close the file.
Step 6: Stop.

12. void nasta(int sum):(non return type function with an argument for billing
purpose)

Step 1: Start

Step 2: Declare variable for roll number.


Step 3: Clear screen
Step 4: Display time and logo using respective functions and other necessary info.
Step 5: Input roll number.
Step 6: Declare a string array and store roll number as a string in it using
convert(char [],int) function.
Step 7: Write roll number and billing information titles in the “order.txt” file.
Step 8: Clear screen
Step 9: Display time and logo using respective functions
Step 10: Display the menu for nasta.

34
Step 11: Ask the user to make a choice among the available options.
Step 12: Is the user’s choice among the available options?
If yes:
Goto step 13.
If no:
Ask the user to make the choice again.
Goto step 11.
Step 13: Ask the user to enter the quantity of the item he/she has chosen.
Step 14: As the user choice matches with one of the available options, perform the
following tasks for the matched option.
14.1: calculate the sum as:
sum=sum+(price of item chosen)*quantity;
14.2: Write the name of item chosen, it’s rate and quantity into the
“order.txt” file.
Step 15: Display “Press 1 if you want to order more”.
Step 16: Take input from the user
Step 17: Is input==1?
If yes:
Goto step 8.
If no:
Call total(sum);
Step 18: Stop.

13. void admin(): (non return type function with no arguments)


Step 1: Start
Step 2: Store password in a variable (say password).
Step 3: Declare a string variable (say ch).
Step 4: Ask input from the user and store to ch.
Step 5: Is password==ch?
If yes:
Call logo(“record”)
If no:
Goto step 6.
Step 6: Stop

35
14. void times(): (non return type function with no arguments)
Step 1: Start
Step 2: Declare t as a time_t variable.
Step 3: Call the time() function and store the time in the address of t.
Step 4: Display the date and time given by the system.
Step 5: Stop

15. int timer(): (return type with no arguments)


Step 1: Start
Step 2: Declare now as a time_t variable.
Step 3: Declare now_tm as a pointer variable under structure of tm(library under
“time.h”).
Step 4: Declare hour as an integer variable.
Step 5:Call time(NULL)(stored under “time.h”).
Step 6: Use localtime(&now) to store the current system time in the now_tm.
Step 7: Assign the value of hour as:
hour = now_tm->tm_hour
( the tm_hour in now_tm structure is stored as integer in hour)
Step 8: Return the value of hour.
Step 9: Stop

36
4.2 Flowchart:

Flowchart in C is a diagrammatic representation of a sequence of logical steps of a


program. Flowcharts use simple geometric shapes to depict processes and arrows
to show relationships and process/data flow. A flowchart in C language is a
graphical representation of an algorithm. Programmers often use it as a
program-planning tool to solve a problem. It makes use of symbols that are
connected among them to indicate the flow of information and processing. The
process of drawing a flowchart for an algorithm is known as “flowcharting”.

37
FLOWCHART FOR THE PROGRAM:
The flowchart for the programs are presented below on the basis of different
functions used in the program.
1. int main():

38
2. void breakfast(int sum):

39
40
41
3.void lunch():

42
43
4.void nonveg(int sum):

44
45
5.void veg(int sum):

46
47
6.void nasta(int sum):

48
7.void dinner(int sum):

49
50
8.void drinks(int sum):

51
52
9.void admin(): 10. void times()

53
11. void logo(char a[]):

54
12. int timer():

55
13.void record():

56
14.void convert(char a[], int n):

57
15.void total(int sum):

58
Chapter 5:
PROGRAMMING AND DEPLOYMENT
5.1 Implementation
After the development and visualisation of the idea of the e-canteen management
system, we used the functions and statements described in Chapter 3 to implement
our logics into programming. As we know pictures speak a thousand words,
following are some pictures that will be able to describe the implementation
procedure of the program. The following cases can be presented:

Case I: Nasta Time(6:00 AM-8:59AM)

Fig 5.0: It shows the first screen which allows the user to enter his/her roll number
which must be entered to access further parts of the program. After entering the
roll number he/she will be directed to the breakfast menu similar to the one shown
in Fig 5.2.

59
Case II: Breakfast Time(9:00 AM-11:59 AM)

Fig 5.1: It shows the first screen which allows the user to enter his/her roll number,
which must be entered to access further parts of the program.

Fig 5.2: After the roll number is entered, he/she will be referred to the breakfast
menu, which can be accessed using valid choices only.

60
Case III: Lunch Time( 12:00 noon-5:59 PM)

Fig 5.3: It shows the first screen which allows the user to enter his/her roll number,
which must be entered to access further parts of the program.

Fig 5.4: After the roll number is entered, he/she will be referred to the lunch menu,
which can be accessed using valid choices only.

61
Case IV: Dinner Time(6:00 PM-9:59 PM)

Fig 5.5: It shows the first screen which allows the user to enter his/her roll number,
which must be entered to access further parts of the program.

Fig 5.6: After the roll number is entered, he/she will be referred to the dinner
menu, which can be accessed using valid choices only.

62
Case V: Closing Time:

Fig 5.7: It shows the screen for closing time, which asks the user to return later.

5.2 Testing
The program was executed several times and modified according to the
requirements to make it as user-friendly as it could be. The program was looked for
by all the 4 members of the team and subsequent changes were made to finalise the
program code.

5.3 Coding
The program, as mentioned in the above chapters, was written in C-programming
language and as C is a procedure-oriented high level programming language, all
the procedures were divided into subsequent modules to get the whole program to
work as one. Here the source code was coded in “project.c” file, and executed
through a popular Integrated Development Environment(IDE), Dev C++.

“project.c” contains different types of main function and different sub


modules(sub functions) which are described below :
A. int main()
This is the main function, which opens two different “.txt” files, “order.txt”
and “record.txt” through file pointers declared in the global declaration section as
f1 and f2 in write and append modes, and retrieves the current hour from timer()

63
function, which is then used by the program itself to display the breakfast, dinner,
lunch, which are functions in themselves, using the if-else ladder. The functions are
further discussed in: void breakfast(int sum),void dinner(int sum),void lunch(). In
case of the failure of times to display any menu, the canteen portal shows the
closed page, which is retrieved with the help of void logo(char[]) and activates the
admin control with void admin() and pauses the system console.
B. void lunch()
This function declares an integer variable roll number and then clears the
screen and retrieves the WELCOME logo from another function void logo(char
[]), so that the program looks aesthetically good. It displays the name of the portal
and also the current system time using the void times() function, which is discussed
further down. It asks for the roll number of the user/customer and after the
entering, the integer type variable is converted into string using void convert(char
[],int) and then the roll number and the billing information topics are put in the
order.txt file using the function of fputs(). This then proceeds to the next program
section containing the management portal topic and system time, along with the
fetched logo of LUNCH MENU from the same void logo(char []). The program
delivers two sorts of choices to the user, veg and non-veg. Using the switch case
statements, the input data from the user takes the user to the desired sections
calling functions void veg(int sum) and void nonveg(int sum) respectively. The
default along with the use of goto does not allow the user to make invalid choice.
C. void breakfast(int sum)
This function also declares an integer variable roll number and then clears
the screen and retrieves the WELCOME logo from another function void logo(char
[]), so that the program looks aesthetically good. It displays the name of the portal
and also the current system time using the void times() function. It asks for the roll
number of the user/customer and after the entering, the integer type variable is
converted into string using void convert(char [],int) and then the roll number and
the billing information topics are put in the order.txt file using the function of
fputs(). The system then proceeds to show the BREAKFAST MENU, retrieved
from logo(char[]). The breakfast menu is shown and the valid choices takes the
user to ask for quantity and converts the quantity to string variable, and puts the
information on the string, and the sum is being added in the declared variable.
Then using selective and jumping structures, the user can choose to ordering more

64
or proceed to order drinks (calling void drinks(int sum))or the termination of order,
which leads to void total(int sum).
D. void dinner(int sum)
This function also declares an integer variable roll number and then clears
the screen and retrieves the WELCOME logo from another function void
logo(char []), so that the program looks aesthetically good. It displays the name of
the portal and also the current system time using the void times() function. It asks
for the roll number of the user/customer and after the entering, the integer type
variable is converted into string using void convert(char [],int) and then the roll
number and the billing information topics are put in the order.txt file using the
function of fputs(). The system then proceeds to show the DINNER MENU,
retrieved from logo(char[]). The dinner menu is shown and the valid choices takes
the user to ask for quantity and converts the quantity to string variable, and puts the
information on the string, and the sum is being added in the declared variable.
Then using selective and jumping structures, the user can choose to order more or
proceed to order drinks (calling void drinks(int sum))or the termination of order,
which leads to void total(int sum).
E. void veg(int sum)
It clears the screen and retrieves the VEG MENU logo from another
function void logo(char []), displays it with system time using void times(). The
veg menu is displayed and the valid choices takes the user to ask for quantity and
converts the quantity to string variable, and puts the information on the string, and
the sum is being added in the declared variable. Then using selective and jumping
structures, the user can choose to order more, order from non-veg menu(calling
void nonveg(int sum)), proceed to order drinks (calling void drinks(int sum))or the
termination of order, which leads to void total(int sum).
F. void nonveg(int sum)
It clears the screen and retrieves the NON-VEG MENU logo from another
function void logo(char []), displays it with system time using void times(). The
veg menu is displayed and the valid choices takes the user to ask for quantity and
converts the quantity to string variable, and puts the information on the string, and
the sum is being added in the declared variable. Then using selective and jumping
structures, the user can choose to order more, order from veg menu(calling void
nonveg(int sum)), proceed to order drinks (calling void drinks(int sum))or the
termination of order, which leads to void total(int sum).

65
G. void drinks(int sum)
It clears the screen and retrieves the DRINKS MENU logo from another
function void logo(char []), displays it with system time using void times(). The
veg menu is displayed and the valid choices takes the user to ask for quantity and
converts the quantity to string variable, and puts the information on the string, and
the sum is being added in the declared variable. Then using selective and jumping
structures, the user can choose to order more, order from veg menu(calling void
nonveg(int sum)), proceed to order non-veg(calling void nonveg(int sum))or the
termination of order, which leads to void total(int sum). This option only arrives
for the lunch time, and for the other meals, only ordering more and terminating the
order are the two options available for the customer to choose from.
H. void total(int sum)
This function receives the sum value from above functions and converts it to
string and puts the order’s total sum in the order.txt using fputs(), closes the
order.txt and summons the void record().
I. void convert(char [],int)
The function converts the integer passed to string variable for easier file
handling process. The passed integer is reversed to make the conversion more
convenient and easier. Then using iterations, conversion of the individual digits
into strings(characters) and storage as a string takes place, and the final string value
is taken as ‘\0’ to avoid any garbage values.
J. void record()
It uses the file pointer previously declared file pointer f1 to open the
“order.txt” in read mode, and using fputc() and fgetc(), retrieves all the information
previously stored from different functions one by one through iteration and puts the
characters one by one in “record.txt” through append mode and also displays the
billing information as the final program screen. It closes both files pointer by the
file pointers f1 and f2.
K. void logo(char a[])
It displays the different logos accessing the logo from a “.txt” file. Declaring
a file pointer fp1, it opens the passed file name in read mode, and then fetches the
characters using fgetc() and character variable ch and displays this on the console
and closes the file pointed by fp1.
L. int timer()

66
It uses the functions stored in time.h header file and by creating a structure
of time, it returns hour as an integer variable upon calling.
M. void times()
It also uses the functions stored in time.h header file and displays the current
system date and time upon calling in the previous functions.
N. void nasta(int sum):
This function also declares an integer variable roll number and then clears
the screen and retrieves the WELCOME logo from another function void logo(char
[]), so that the program looks aesthetically good. It displays the name of the portal
and also the current system time using the void times() function. It asks for the roll
number of the user/customer and after the entering, the integer type variable is
converted into string using void convert(char [],int) and then the roll number and
the billing information topics are put in the order.txt file using the function of
fputs(). The system then proceeds to show the NASTA MENU, retrieved from
logo(char[]). The breakfast menu is shown and the valid choices takes the user to
ask for quantity and converts the quantity to string variable, and puts the
information on the string, and the sum is being added in the declared variable.
Then using selective and jumping structures, the user can choose to order more or
proceed to the termination of order, which leads to void total(int sum).
O. void admin():
This function is particularly designed for the admin to check the records of
his business at the end of the day. While the closed() function is in play, if the
admin enters the secret password(known only by the admin), the program displays
the contents of the record file. Entering any random string will not access the
record file.

67
Chapter 6:
RESULT AND DISCUSSION

The results of the program and the discussions are presented below with the help of
following screenshots of the output:

Case I: Nasta Time(6:00 AM-8:59 AM)

Fig 6.0.1: It shows the first screen which allows the user to enter his/her roll
number, which must be entered to access further parts of the program.

Fig 6.0.2: After entering the roll number in integer form, the above shown page is
displayed, where the user is welcomed and asked to pick his/her choice for order.

68
Fig 6.0.3: The user is asked to order his choice and quantity is asked to be entered
on only valid choices as explained in Fig 6.6. On entering, he/she is asked if he/she
wants to order more, pressing 1 takes the user to the output shown in Fig 6.0.2,
where he is allowed to order more and pressing any other key will take the user to
Fig 6.0.4.

Fig 6.0.4: This is the termination of order followed by the billing amount
presented on the console.

Case II: Breakfast Time(9:00 AM-11:59 AM)

69
Fig 6.1: It shows the first screen which allows the user to enter his/her roll number,
which must be entered to access further parts of the program.

Fig 6.2:After entering the roll number in integer form, the above shown page is
displayed, where the user is welcomed and asked to pick his/her choice for order.

70
Fig 6.3: The customer can enter the choice, and then on valid choice, the quantity
is asked by the program and on entering the quantity, the options appear as shown
in Fig 6.4.

Fig 6.4: The following options are created and the pressing of 1 will take the user
to the result as shown in Fig 6.2, pressing of 2 will take the user to the result as
shown in Fig 6.5 below and pressing of 3 will terminate the order and display the
billing information as in Fig 6.7.

71
Fig 6.5: The drinks menu is shown and the user is asked to order his/her choice
and valid choice results into the asking of quantity, and after the entering of
quantity, the user is again asked some options as in Fig 6.6.

Fig 6.6: The entering of quantity will give 2 options. In case of invalid choice, the
user is asked to enter the choice again, until the choice is correct as shown in the
figure. This invalid option works in all the previous choices and all the upcoming
choices in the different cases that are offered to the customer by the program.
Pressing of 1 will take the program to Fig 6.5 and pressing of 2 will take the
program to Fig 6.7.

72
Fig 6.7 The billing information is displayed as explained by the coding, where the
order is first gradually stored in the “order.txt” file, and then retrieved from there as
a whole segment on the console screen.

Case III: Lunch Time( 12:00 noon-5:59 PM)

Fig 6.8: It shows the first screen which allows the user to enter his/her roll number,
which must be entered to access further parts of the program.

73
Fig 6.9: After the roll number is entered, he/she will be referred to the lunch menu,
which is further divided into veg and non-veg. Pressing of 1 will take the user to
Fig 6.10 and pressing of 2 will take the user to Fig 6.12.

Fig 6.10: It displays the veg menu and asks the user to enter the choice from
options presented and the valid option asks the user to input quantity, and on this
entering the options are presented as shown in Fig 6.11.

74
Fig 6.11: In the case of invalidity, as explained previously in fig 6.6, valid choice is
again asked, pressing 1 will take to fig 6.10, 2 will take to fig 6.12, 3 will take to
Fig 6.

Fig 6.12: It shows the non-veg menu and asks the user for his/her choice, and for
valid choice, it asks for quantity and displays options like for veg menu in Fig 6.11
and takes the user to the subsequent part.

75
Fig 6.13: As for the breakfast, drinks menu is shown and valid choice leads to
asking of quantity and displays options like for veg menu in Fig 6.11, and takes the
user to the subsequent part.

Fig 6.14: This shows the completion of the order and as explained in Fig 6.7,
displays the total orders and total sum on the screen.

Case IV: Dinner Time(6:00 PM-9:59 PM)

76
Fig 6.15: It shows the first screen which allows the user to enter his/her roll
number, which must be entered to access further parts of the program.

Fig 6.16: After the roll number is entered, he/she will be referred to the dinner
menu, which can be accessed using valid choices only. The valid choice leads to
asking for the quantity.

77
Fig 6.17: After the intake of quantity of order, the program displays 3 options, and
only valid options proceed to further pages, as explained in above cases and
figures. The pressing of 1 will take the user to Fig 6.16, 2 to Fig 6.18 and 3 to Fig
6.19.

Fig 6.18:The drinks menu is displayed and the user is allowed to make a valid
choice, and the quantity is asked as in the Fig 6.6, he/she is given choices to order
more or complete the order. The completion of order leads to Fig 6.19.

Fig 6.19: As explained in the previous completion order parts, it displays the total
order in the console screen.

78
Case V: Closing Time:

Fig 6.20: It shows the screen for closing time, which asks the user to return later.
The admin can however press the secret key to view all the available records as
shown in Fig 6.21.

Fig 6.21: It displays all the records present in the “record.txt” file for the admin
after he/she enters the secret key.

79
Chapter 7:
CONCLUSION

After several executions, testing and modifications, the following conclusions can
be made from the program “PULCHOWK E-CANTEEN MANAGEMENT
PORTAL”:
➔ The file handling procedures when combined with different logics and ideas
can be applied to create logical database systems, which are a very crucial
part of the modern day-to-day life we live in.
➔ This program can be compared to a restaurant computer service, which
allows the user to efficiently choose the dishes and avoid queue in this age
and time, especially after the pandemic we recently faced during COVID-19
➔ The program allows the user to have the menu of the meal according to the
system time, and it runs efficiently.
➔ Different ASCII code-arts can be manipulated in the program to make the
program look more user friendly and aesthetic.
➔ The “record.txt” file can be opened by the admin to watch all the orders
carried out during different transactions.

80
REFERENCES

1.https://stackoverflow.com/questions/701524/getting-the-current-hour-in-c-using-t
ime-h (website referred to in chapter 3.8 )

2.https://reactgo.com/c-program-current-date-time/#:~:text=In%20C%20language
%2C%20we%20can,()%20and%20ctime()%20functions.&text=Note%3A%20The
%20time()%20%2C%20ctime,h%20header%20file.

3.https://www.decodejava.com

4.https://www.scaler.com/

5. https://javatpoint.com/

6.https://www.programiz.com/

7.https://www.geeksforgeeks.org/

81
APPENDIX
Source code of the Program:
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<time.h> //to use the system's time

void lunch();
void nasta(int sum);
void breakfast(int sum);
void dinner(int sum);
void veg(int sum);
void nonveg(int sum);
void drinks(int sum);
void total(int sum);
void convert(char [],int);
void record();
int timer();
void times();
void logo(char []);
void admin();

FILE *f1;
FILE *f2;

int main()
{
f1=fopen("order.txt","w"); //To store the current order
f2=fopen("record.txt","a"); //To store the history of orders

//display different menus based on the time of the day


int hr=timer();
if(hr>=6 && hr<=8)
{
nasta(0);
}
else if(hr>8 && hr<=11)
{
breakfast(0);

82
}
else if(hr>11 && hr<=17)
{
lunch();
}
else if(hr>17 && hr<22)
{
dinner(0);
}
else
{
logo("closed.txt");
times();
admin();
}
system(“pause”); \\to execute the program from outside too.
return 0;
}

//The actual breakfast menu(nasta)


void nasta(int sum)
{
int roll;
system("cls");
logo("welcome.txt"); //display the welcome logo
times(); //display the time
printf("\n\n\n\tPULCHOWK E-CANTEEN MANAGEMENT PORTAL\n\t\t");
printf("\n\t\tEnter your roll no: ");
scanf("%d",&roll);
char r[10];
convert(r,roll); //convert number into string to write into the file
fputs("Roll No:\t",f1);
fputs(r,f1);
fputs("\nItem\t\t\t|\tRate\t|\tQuantity\t|\n",f1);
order: ; //To take more orders
system("cls");
int qty;
logo("nasta.txt");
times();
printf("\t\tWelcome sir! \n");

83
printf("\t\t1. Omelette(40)\n\t\t2. Chana Anda(40)\n\t\t3. Bread and jam(30)\n\t\t4. Black
tea(10)\n\t\t5. Milk Tea(15)\n\t\t6. Doughnut(15)\n\t\t");
printf("What would you like to order? ");
up: ;
char check=getche(); //Take order
//To retake input in case of invalid input
if(check=='1' || check=='2' || check=='3' || check=='4' || check=='5' || check=='6')
goto down;
else
{
printf("\n\tInvalid choice. Try again. ");
goto up;
}
down: ;
printf("\n\t\tEnter the quantity:");
scanf("%d", &qty); //Specify Quantity
char q[10];
convert(q,qty);
//calculate the billing amount after each order
switch(check)
{
case '1':
sum=sum+(40*qty);
fputs("Omelette\t\t\t|\t40\t|\t",f1);
fputs(q,f1);
fputs("\t\t|\n",f1);
break;

case '2':
sum=sum+(40*qty);
fputs("Chana Anda\t\t|\t40\t|\t",f1);
fputs(q,f1);
fputs("\t\t|\n",f1);
break;

case '3':
sum=sum+(30*qty);
fputs("Bread and Jam\t\t|\t30\t|\t",f1);
fputs(q,f1);
fputs("\t\t|\n",f1);

84
break;
case '4':
sum=sum+(10*qty);
fputs("Black Tea\t\t|\t10\t|\t",f1);
fputs(q,f1);
fputs("\t\t|\n",f1);
break;
case '5':
sum=sum+(15*qty);
fputs("Milk Tea\t\t|\t15\t|\t",f1);
fputs(q,f1);
fputs("\t\t|\n",f1);
break;
case '6':
sum=sum+(15*qty);
fputs("Doughnut\t\t|\t15\t|\t",f1);
fputs(q,f1);
fputs("\t\t|\n",f1);
break;
}
printf("Enter 1 to order more");
char ord;
ord=getche();
if(ord=='1')
goto order;
else
total(sum);
}

//The breakfast menu


void breakfast(int sum)
{
int roll;
system("cls");
logo("welcome.txt"); //display the welcome logo
times(); //display the time
printf("\n\n\n\tPULCHOWK E-CANTEEN MANAGEMENT PORTAL\n\t\t");
printf("\n\t\tEnter your roll no: ");
scanf("%d",&roll);
char r[10];

85
convert(r,roll); //convert number into string to write into the file
fputs("Roll No:\t",f1);
fputs(r,f1);
fputs("\nItem\t\t\t|\tRate\t|\tQuantity\t|\n",f1);

order: ; //To take more orders


system("cls");
int qty;
logo("breakfast.txt");
times();
printf("\t\tWelcome sir/ma'am! \n");
printf("\t\t1. Veg. Khana(70)\n\t\t2. Chicken Khana(100)\n\t\t3. Mutton Khana(150)\n\t\t");
printf("What would you like to order? ");
up:;
char check=getche(); //Take order
//To retake input in case of invalid input
if(check=='1' || check=='2' || check=='3' )
goto down;
else
{
printf("\n\tInvalid choice. Try again. ");
goto up;
}
down:;
printf("\n\t\tEnter the quantity:");
scanf("%d", &qty); //Specify Quantity
char q[10];
convert(q,qty);
//calculate the billing amount after each order
switch(check)
{
case '1':
sum=sum+(70*qty);
fputs("Veg Khana\t\t|\t70\t|\t",f1);
fputs(q,f1);
fputs("\t\t|\n",f1);
break;

case '2':
sum=sum+(100*qty);

86
fputs("Chicken Khana\t\t|\t100\t|\t",f1);
fputs(q,f1);
fputs("\t\t|\n",f1);
break;

case '3':
sum=sum+(150*qty);
fputs("Mutton Khana\t\t|\t150\t|\t",f1);
fputs(q,f1);
fputs("\t\t|\n",f1);
break;
}
//To enable ordering of different items from different menus
printf("\n\tPress 1 to continue ordering.\n\tPress 2 to order drinks.\n");
printf("\tPress 3 to indicate completion of ordering.");
here:;
char check1=getche();
switch(check1)
{
case '1':
goto order;
break;
case '2':
drinks(sum);
break;
case '3':
total(sum);
break;
default:
printf("\n/tPlease make a valid choice. ");
goto here;
}

//The lunch menu consisting of multiple sub menus


void lunch()
{
int roll;
system("cls");

87
logo("welcome.txt");
printf("\n\n\n\tPULCHOWK E-CANTEEN MANAGEMENT PORTAL\n\t\t");
times();
printf("\n\t\tEnter your roll no: ");
scanf("%d",&roll);
char r[10];
convert(r,roll);
fputs("Roll No:\t",f1);
fputs(r,f1);
fputs("\nItem\t\t\t|\tRate\t|\tQuantity\t|\n",f1);
system("cls");
logo("lunch.txt");
printf("\n\n\n\tPULCHOWK E-CANTEEN MANAGEMENT PORTAL\n\t\t");
times();
printf("\t\tWelcome sir/ma'am! \n\n\tWhat would you like to order?\n");
printf("\t\t1. Veg\n\t\t2. Non-veg\n");
here: ; //To prevent system failure in case of wrong option selection
char check=getch();
switch(check)
{
case '1':
veg(0);
break;
case '2':
nonveg(0);
break;
default:
printf("\n\tPlease make a valid choice.");
goto here;
}
}

//The non-veg menu


void nonveg(int sum)
{
order:;
system("cls");
logo("nonveg.txt");
times();
int qty;

88
printf("\t\t1.Chicken Momo(110)\n\t\t2. Chicken Chowmein(70)\n\t\t3. Chicken
sausage(30)\n\t\t4. Chicken Pizza(200)\n\t\t5. Chicken Sizzler(300)\n");
printf("\tPlease select an item:");
up:;
char check=getche();
if(check=='1' || check=='2' || check=='3' || check=='4' || check=='5')
goto down;
else
{
printf("\n\tInvalid choice. Try again. ");
goto up;
}
down:;
printf("\n\tEnter the quantity:");
scanf("%d", &qty);
char q[10];
convert(q,qty);
switch(check)
{
case '1':
sum=sum+(110*qty);
fputs("Chicken Momo\t\t|\t110\t|\t",f1);
fputs(q,f1);
fputs("\t\t|\n",f1);
break;

case '2':
sum=sum+(70*qty);
fputs("Chicken Chowmein\t|\t70\t|\t",f1);
fputs(q,f1);
fputs("\t\t|\n",f1);
break;

case '3':
sum=sum+(30*qty);
fputs("Chicken Sausage\t\t|\t30\t|\t",f1);
fputs(q,f1);
fputs("\t\t|\n",f1);
break;

89
case '4':
sum=sum+(200*qty);
fputs("Chicken Pizza\t\t|\t200\t|\t",f1);
fputs(q,f1);
fputs("\t\t|\n",f1);
break;

case '5':
sum=sum+(300*qty);
fputs("Chicken Sizzler\t\t|\t300\t|\t",f1);
fputs(q,f1);
fputs("\t\t|\n",f1);
break;

}
printf("\n\tPress 1 to continue ordering.\n\tPress 2 to order from veg menu.\n");
printf("\tPress 3 to order drinks\n\tPress 4 to indicate completion of ordering.");
here:;
char check1=getche();
switch(check1)
{
case '1':
goto order;
break;
case '2':
veg(sum);
break;
case '3':
drinks(sum);
break;
case '4':
total(sum);
break;
default:
printf("\n\tPlease make a valid choice. ");
goto here;
}

90
//The veg menu
void veg(int sum)
{
int qty;
order:;
system("cls");
logo("veg.txt");
times();
printf("\t\t1. Veg Momo(50)\n\t\t2. Veg. Chowmein(25)\n\t\t3. Samosa Tarkari(30)\n\t\t4. Aalu
chana(20)\n\t\t5. Alu chop(10)\n\t\t6. Cheese Pizza(180)\n");
printf("\tWhat would you want? ");
up:;
char check=getche();
if(check=='1' || check=='2' || check=='3' || check=='4' || check=='5' || check=='6')
goto down;
else
{
printf("\n\tInvalid choice. Try again. ");
goto up;
}
down:
printf("\n\tEnter the quantity: ");
scanf("%d",&qty);
char q[10];
convert(q,qty);
switch(check)
{
case '1':
sum=sum+(50*qty);
fputs("Veg. Momo\t\t|\t50\t|\t",f1);
fputs(q,f1);
fputs("\t\t|\n",f1);
break;

case '2':
sum=sum+(25*qty);
fputs("Veg. Chowmein\t\t|\t25\t|\t",f1);
fputs(q,f1);
fputs("\t\t|\n",f1);

91
break;

case '3':
sum=sum+(30*qty);
fputs("Samosa Tarkari\t\t|\t30\t|\t",f1);
fputs(q,f1);
fputs("\t\t|\n",f1);
break;
case '4':
sum=sum+(20*qty);
fputs("Aalu Chana\t\t|\t20\t|\t",f1);
fputs(q,f1);
fputs("\t\t|\n",f1);
break;
case '5':
sum=sum+(10*qty);
fputs("Aalu Chop\t\t|\t10\t|\t",f1);
fputs(q,f1);
fputs("\t\t|\n",f1);
break;
case '6':
sum=sum+(180*qty);
fputs("Cheese Pizza\t\t|\t180\t|\t",f1);
fputs(q,f1);
fputs("\t\t|\n",f1);
break;
}
printf("\n\tPress 1 to continue ordering.\n\tPress 2 to order from non-veg menu.\n");
printf("\tPress 3 to order drinks\n\tPress 4 to indicate completion of ordering.");
here:;
char check1=getche();
switch(check1)
{
case '1':
goto order;
break;
case '2':
nonveg(sum);
break;
case '3':

92
drinks(sum);
break;
case '4':
total(sum);
break;
default:
printf("\n\tPlease make a valid choice. ");
goto here;
}

//The dinner menu


void dinner(int sum)
{
int roll;
system("cls");
logo("welcome.txt");
printf("\n\n\n\tPULCHOWK E-CANTEEN MANAGEMENT PORTAL\n\t\t");
times();
printf("\n\t\tEnter your roll no: ");
scanf("%d",&roll);
char r[10];
convert(r,roll);
fputs("Roll No:\t",f1);
fputs(r,f1);
fputs("\nItem\t\t\t|\tRate\t|\tQuantity\t|\n",f1);
order:
system("cls");
int qty;
logo("dinner.txt");
times();
printf("\t\tWelcome sir/ma'am! \n");
printf("\t\t1. Veg. Khana(70)\n\t\t2. Chicken Khana(100)\n\t\t3. Mutton Khana(150)\n\t\t4.Roti
Set(50)\n\t\t");
printf("What would you like to order? ");
up:;
char check=getche();
if(check=='1' || check=='2' || check=='3' || check=='4')

93
goto down;
else
{
printf("\n\tInvalid choice. Try again. ");
goto up;
}
down:
printf("\n\t\tEnter the quantity:");
scanf("%d", &qty);
char q[10];
convert(q,qty);
switch(check)
{
case '1':
sum=sum+(70*qty);
fputs("Veg Khana\t\t|\t70\t|\t",f1);
fputs(q,f1);
fputs("\t\t|\n",f1);
break;

case '2':
sum=sum+(100*qty);
fputs("Chicken Khana\t\t|\t100\t|\t",f1);
fputs(q,f1);
fputs("\t\t|\n",f1);
break;

case '3':
sum=sum+(150*qty);
fputs("Mutton Khana\t\t|\t150\t|\t",f1);
fputs(q,f1);
fputs("\t\t|\n",f1);
break;
case '4':
sum=sum+(50*qty);
fputs("Roti Set\t\t|\t50\t|\t",f1);
fputs(q,f1);
fputs("\t\t|\n",f1);
break;
}

94
printf("\n\tPress 1 to continue ordering.\n\tPress 2 to order drinks.\n");
printf("\tPress 3 to indicate completion of ordering.");
here:;
char check1=getche();
switch(check1)
{
case '1':
goto order;
break;
case '2':
drinks(sum);
break;
case '3':
total(sum);
break;
default:
printf("\n\tPlease make a valid choice.");
goto here;

//The drinks menu


void drinks(int sum)
{
int qty;
order:
system("cls");
logo("drinks.txt");
times();
printf("\t\t1. Black tea(10)\n\t\t2. Milk tea(15)\n\t\t3.Soft
Drinks(40)\n\t\t4.Frooti(25)\n\t\t5.Lassi(50)\n\t");
printf("What would you like?");
up:;
char check=getche();
if(check=='1' || check=='2' || check=='3' || check=='4' || check=='5')
goto down;
else

95
{
printf("\n\tInvalid choice. Try again. ");
goto up;
}
down:
printf("\n\tEnter the quantity:");
scanf("%d",&qty);
char q[10];
convert(q,qty);
switch(check)
{
case '1':
sum=sum+(10*qty);
fputs("Black Tea\t\t|\t10\t|\t",f1);
fputs(q,f1);
fputs("\t\t|\n",f1);
break;

case '2':
sum=sum+(15*qty);
fputs("Milk Tea\t\t|\t15\t|\t",f1);
fputs(q,f1);
fputs("\t\t|\n",f1);
break;

case '3':
sum=sum+(40*qty);
fputs("Soft Drinks\t\t|\t40\t|\t",f1);
fputs(q,f1);
fputs("\t\t|\n",f1);
break;
case '4':
sum=sum+(25*qty);
fputs("Frooti\t\t\t|\t25\t|\t",f1);
fputs(q,f1);
fputs("\t\t|\n",f1);
break;
case '5':
sum=sum+(50*qty);
fputs("Lassi\t\t\t|\t50\t|\t",f1);

96
fputs(q,f1);
fputs("\t\t|\n",f1);
break;
}
//To manage drinks menu according to the time of the day
int hr=timer();
if(hr>=11 && hr<=17)
{
printf("\n\tPress 1 to continue ordering.\n\tPress 2 to order from non-veg menu.\n");
printf("\tPress 3 to order from veg menu.\n\tPress 4 to indicate completion of ordering. ");
here:;
char check1=getche();
switch(check1)
{
case '1':
goto order;
break;
case '2':
nonveg(sum);
break;
case '3':
veg(sum);
break;
case '4':
total(sum);
break;
default:
printf("\n\tPlease make a valid choice. ");
goto here;

}
}
else
{
printf("\tPress 1 to order more and 2 to stop ordering.");
here2:;
char check1=getche();
switch(check1)
{
case '1':

97
goto order;
break;
case '2':
total(sum);
break;
default:
printf("\n\tPlease make a valid choice.");
goto here2;
}
}
}

//Store the billing amount into the files


void total(int sum)
{
system("cls");
char s[10];
convert(s,sum);
fputs("\t\t\tTotal:",f1);
fputs(s,f1);
fputs("\n----------------------------------------------------------------------------\n",f1);
fclose(f1);
record(); //Keep record of the order in another file
}

//To convert integers into strings for easier file handling


void convert(char a[], int n)
{
int i = 0, rem, rn = 0, count = 0;
//reverse the number before conversion as taking letters from the end is easier
while (n > 0)
{
rem = n % 10;
rn = rn * 10 + rem;
n = n / 10;
count++; //count the digits of the number
}
//convert individual digits into strings(characters) and store as a string
for (i = 0; i < count; i++)
{

98
rem = rn % 10;
a[i] = (char)(rem + 48);
rn /= 10;
}
a[i] = '\0'; //terminate the string to avoid garbage values
}

//keep record of the orders for future use


void record()
{
char ch;
f1=fopen("order.txt","r");
while((ch=fgetc(f1)) != EOF)
{
putc(ch,f2); //copy data from order file to record file
printf("%c",ch); //display the customer's current order
}
fclose(f1);
fclose(f2);
}

//admin’s secret access


void admin()
{
char password[]="@dminControl";
char ch[100];
scanf("%s",ch);
if(strcmp(password,ch)==0)
{
system("cls");
printf("\t\t\tWelcome Admin\n\n\n");
logo("record.txt");
}
}

//display the different logos accessing the logo from a .txt file
void logo(char a[])
{
FILE *fp1;

99
fp1=fopen(a,"r");
char ch;
while((ch = fgetc(fp1)) != EOF)
{
printf("%c", ch);
}
fclose(fp1);
}

//display the system time


void times()
{
time_t t;
time(&t);
printf("\n\t\t\t\t\t\t\t%s", ctime(&t));

//extract the hour part of the system time for operations mentioned above
int timer()
{
time_t now;
struct tm *now_tm;
int hour;

now = time(NULL);
now_tm = localtime(&now);
hour = now_tm->tm_hour;
return hour;
}

100

You might also like