0% found this document useful (0 votes)
2K views12 pages

Ds Mini Project

This document describes a mini project to create an ice cream parlour sales system using data structures in C. The key features include an ice cream menu for ordering, an order tracking system to view pending and completed orders, and an admin login with privileges to edit the menu, view inventory and sales reports. The project uses linked lists to implement the menu and completed orders, and a queue to track pending orders. Functions include adding and removing items from the linked lists and queue, as well as displaying the menu and order statuses.

Uploaded by

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

Ds Mini Project

This document describes a mini project to create an ice cream parlour sales system using data structures in C. The key features include an ice cream menu for ordering, an order tracking system to view pending and completed orders, and an admin login with privileges to edit the menu, view inventory and sales reports. The project uses linked lists to implement the menu and completed orders, and a queue to track pending orders. Functions include adding and removing items from the linked lists and queue, as well as displaying the menu and order statuses.

Uploaded by

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

DS MINI PROJECT

AIM: To implement an ice-cream parlour sales system using data structures in


C.

FEATURES:
● Ice Cream menu and ordering
● Order tracking system (Can view pending and completed orders)
● Admin login and privilege to complete the order
● Admin can edit the menu (add or delete the ice creams)
● Admin can view the inventory and daily sales

DATA STRUCTURES USED:


1. Linked List
● 2 Linked Lists used: One for menu items and one for completed
orders
● Add and delete functions of linked list used to add and delete items
and complete the orders
● To display the menu
2. Queue
● Queue used for getting pending orders
● Enqueue and Dequeue functions of queue are used
● Display function is used to display the pending orders

TEAM MEMBERS
HARSH VARTAK (60004180028)
HRISHIKESH AVANOOR (60004180033)
HIMANSHU SANKLECHA(60004180032)

CODE:
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<time.h>
#include<string.h>
#include<malloc.h>
#include<ctype.h>
#include<process.h>
#include<windows.h>

static int orders=100;

/*for linked list*/


struct item{
char name[11];
int price;
int orders;
struct item *next;
};

/*for queue of orders*/


struct queue{
int orderNo;
struct queue *next;
};

struct complete{
int orderNo;
struct queue *next;
};

struct item *start=NULL;


struct complete *c_start;
struct queue *head=NULL;
struct queue *tail=NULL;

//basic functions
void addItem(char n[],int p);
void enqueue(int orderNo);
int dequeue(); //returns order no.
void addCompleted(int orderNo);
int itemsSize();
int queueSize();

void create();
void menu();
void takeOrder();
void showStatus();

//admin functions
void addItem_admin();
void deleteItem();
void adminStatus();
void adminLogin();
void changeStatus();
void gotoxy(int x,int y);
void welcome();
int peekQueue();
int itemsSize(){
int c=0;
struct item *ptr;
ptr=start;
while(ptr!=NULL){
c++;
ptr=ptr->next;
}
return c;
}

int queueSize(){
int c=0;
struct queue *ptr;
ptr=head;
while(ptr!=NULL){
c++;
ptr=ptr->next;
}
return c;
}

void addItem(char n[],int p){


struct item *ptr,*new_item;
new_item=(struct item *)malloc(sizeof(struct item));
new_item->price=p;
strcpy(new_item->name,n);
new_item->orders=0;
new_item->next=NULL;

if(start==NULL){
start=new_item;
}else{
ptr=start;
while(ptr->next!=NULL){
ptr=ptr->next;
}
ptr->next=new_item;
}
}

void enqueue(int orderNo){


struct queue *new_order;
new_order=(struct queue *)malloc(sizeof(struct queue));
new_order->orderNo=orderNo;
new_order->next=NULL;
if(head==NULL){ //queue is empty
head=new_order;
tail=head;
}else{ //only one order is in queue
tail->next=new_order;
tail= tail->next;
}
}

void welcome(){
int i,k=6,r,q;
gotoxy(40,5);
for(i=0;i<=50;i++)
printf("*");
for(i=0;i<20;i++)
{
gotoxy(40,k);
printf("*");
gotoxy(90,k);
printf("*");
printf("\n");
k++;
}
gotoxy(41,25);
for(i=0;i<=49;i++)
printf("*");
gotoxy(45,7);
printf("**** WELCOME TO 3H's ICE CREAM PARLOUR****");
gotoxy(50,8);
printf("what we offer?");
gotoxy(45,9);
printf("->fast service");
gotoxy(45,10);
printf("->hygiene");
gotoxy(45,11);
printf("->Natural");
gotoxy(45,12);
printf("->order tracking system");
gotoxy(50,14);
printf("menu is being loaded....");
gotoxy(50,15);
for(r=0;r<=20;r++)
{
for(q=0;q<=10000000;q++);
printf("%c",177);
}
gotoxy(50,16);
printf("press any key to start");

getch();
}

int dequeue(){
struct queue *ptr;
if(head==NULL){ //queue empty
return -1;
}else if(head==tail){ //single element
ptr=head;
head=NULL;
tail=NULL;
}else{
ptr=head;
head=head->next;
}
return ptr->orderNo;
}

void addCompleted(int orderNO){


struct complete *new_complete ;
new_complete =(struct complete *)malloc(sizeof(struct complete));
new_complete->orderNo=orderNO;
new_complete->next=c_start;
c_start=new_complete;
}

void addItem_admin(){

char n[10];
int p;
printf("enter name of the ice cream\n");
scanf("%s",&n);
printf("enter amount\n");
scanf("%d",&p);
addItem(n,p);
printf("%s was added in the menu",n);
getch();
}

void deleteItem(){
int k=1,choice,p;
struct item *ptr,*pre;
ptr=start;
printf("********************************\n");
printf("sr no.\t flavours\t price\n");
printf("********************************\n");
while(ptr!=NULL){

printf("%d\t %s\t %d rs\n\n",k,ptr->name,ptr->price);


ptr=ptr->next;
k++;
}
ptr=start;
printf("select the item to delete\n");
scanf("%d",&choice);
if(choice<=itemsSize() && choice>0){
choice--;
while(choice>0){
choice--;
pre=ptr;
ptr=ptr->next;
}
printf("are you sure you want to delete %s? (1/0)\n\n",ptr->name);
scanf("%d",&p);
if(p==1){
pre->next=ptr->next;
free(ptr);
printf("item was deleted\n");
printf("\npress any key to return\n");
getch();
}
else if(p==0)
{
printf("item was not deleted\n");
printf("\npress any key to return\n");
getch();
system("cls");
}
}
else{
printf("please select between 1 to %d\n",itemsSize());
deleteItem();
}
}

void create(){
int i=0;
char name[100];
char arr_n[11][100]={"mango ","sitaphal ","litchi ","coconut ","jackfruit ","kesar pista","chickoo
","chocobite ","kaju kismis","anjeer "};
int arr_p[]={60,50,50,70,50,60,70,50,70,70};
for(i=0;i<10;i++){
strcpy(name,arr_n+i);
addItem(name,arr_p[i]);
}
}

void menu(){
int k=1;
struct item *ptr;
ptr=start;
printf("********************************\n");
printf("sr no.\t flavours\t price\n");
printf("********************************\n");
while(ptr!=NULL){
printf("%d\t %s\t %d rs\n\n",k,ptr->name,ptr->price);
ptr=ptr->next;
k++;
}
takeOrder();
getch();
}

void takeOrder(){
struct item *iceCream;
iceCream=start;
int choice,orderNO;
char again;
printf("enter ice cream no.\n\n");
scanf("%d",&choice);

if(choice<=itemsSize() && choice>0){


choice--;
while(choice>0){
choice--;
iceCream=iceCream->next;

}
printf("you selected %s\n\n",iceCream->name);
iceCream->orders+=1;
orderNO=orders++;
printf("your order no is %d\n",orderNO);
enqueue(orderNO);
printf("\npress any key to return\n\n");

}else{
printf("please select between 1 to %d\n\n",itemsSize());
takeOrder();
}
}

void showStatus(){
char c;
struct queue *ptr;
ptr=head;
printf("pending\n");
while(ptr!=NULL){
printf("%d\n",ptr->orderNo);
ptr=ptr->next;
}

ptr=c_start;
printf("\ncompleted\n");
while(ptr!=NULL){
printf("%d\n",ptr->orderNo);
ptr=ptr->next;
}
printf("\n\npress any key\n\n");
getch();
}

void adminStatus(){
struct item *iceCream;
int price,orders,total,sale=0;
char name[11];
iceCream=start;
printf("product price orders total\n");
while(iceCream!=NULL){
strcpy(name,iceCream->name);
price =iceCream->price;
orders=iceCream->orders;
total = price*orders;
printf("%s \t%d\t%d\t%d\n",name,price,orders,total);
sale+=total;
iceCream=iceCream->next;
}
printf("total sale = %d\n",sale);
printf("\npress any key to return\n");
getch();
}

void adminLogin(){
char pass[10];
char password[]="qwerty";
int result=-1,c;
int p=0;
printf("enter password for admin\n");
do{
pass[p]=getch();
if(pass[p]!='\r'){
printf("*");
}
p++;
}while(pass[p-1]!='\r');
pass[p-1]='\0';
result=strcmp(pass,password);
if(result!=0){
printf("incorrect password\n");
}else{
do{
system("cls");
printf("\n\n1.inventory\t2.add item\t3.delete item\t4.change status \t5.logout\n");
scanf("%d",&c);
switch(c){
case 1:adminStatus();
break;
case 2:addItem_admin();
break;
case 3:deleteItem();
break;
case 4:changeStatus();
break;
case 5:break;
default:;
}
}while(c!=5);
}
}

void changeStatus(){
int c=-1,c1=0,orderNo;
system("cls");
showStatus();

while((c!=0) && (queueSize()>0)){


c1=peekQueue();
if(c!=1){
printf("press 1 to complete order %d \n 0 to exit\n",c1);
fflush(stdout);
scanf(" %d",&c);
}
if (c==1){
orderNo=dequeue();
addCompleted(orderNo);
system("cls");
printf("order no %d was completed\n",orderNo);
showStatus();
if(queueSize()<=0){
printf("no pending orders\n\n");
return ;
}
}else{
break;
}
c1=peekQueue();
printf("press 1 to complete order %d \n 0 to exit\n",c1);
fflush(stdout);
scanf("%d",&c);
}
}

void gotoxy(int x,int y){


COORD coord;
HANDLE a;
coord.X=x;
coord.Y=y;
a=GetStdHandle(STD_OUTPUT_HANDLE);

SetConsoleCursorPosition(a,coord);
}

int peekQueue(){
return head->orderNo;

int main()
{
int c;
welcome();
create();

do{
system("cls");
printf("********main menu*********\n\n");
printf("items in menu %d \t pending orders %d\n\n",itemsSize(),queueSize());
printf(" 1. MENU AND ORDER\n\n 2. ORDER STATUS\n\n 3. ADMIN LOGIN\n\n 4.
EXIT\n\n");
printf(" enter choice\n");
scanf("%d",&c);
switch(c)
{
case 1: menu();
break;
case 2: showStatus();
break;
case 3: adminLogin();
break;

case 4:break;
}
}
while(c!=4);

OUTPUT:

You might also like