└── DSA PROJECT └── Hostel Management System ├── main.exe ├── main.cpp ├── Booking.h ├── Libary Student.h ├── libary Admin.h ├── Canteen.h ├── Contact_book.h └── Employ.h /DSA PROJECT/Hostel Management System/main.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mustafa-Hassan2001/DSA-Project/HEAD/DSA PROJECT/Hostel Management System/main.exe -------------------------------------------------------------------------------- /DSA PROJECT/Hostel Management System/main.cpp: -------------------------------------------------------------------------------- 1 | //Assalamoalikum For Log-in 2 | //Username : Mustafa 3 | //password : 1234 4 | 5 | //===================== Start of Header Files ================ 6 | 7 | #include 8 | #include 9 | #include // It defines the manipulator functions setbase() , setfill() and setw() 10 | #include // time() function in C++ returns the current calendar time as an object of type time_t 11 | #include // It includes functions involving memory allocation, process control, conversions 12 | #include //declares a set of functions to classify (and transform) individual characters. For example, isupper() 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include "Libary Student.h" 18 | #include "libary Admin.h" 19 | #include "Employ.h" 20 | #include "Contact_book.h" 21 | #include "Canteen.h" 22 | #include "Booking.h" 23 | 24 | //===================== Start of Header Files ================ 25 | 26 | using namespace std; 27 | 28 | //Concept of enum 29 | enum week{Sunday , Monday, Tuesday, Wednesday, Thursday,Friday, Saturday}; 30 | enum month{January, Febuary, March, April, May, June, July, August, September, October, November, December}; 31 | 32 | 33 | //To Display Date on Screen 34 | void date(){ 35 | time_t T= time(NULL); 36 | struct tm tm = *localtime(&T); //it can use by time.h header file inn which struct is tm is by default to show date 37 | cout< clock()); 46 | } 47 | 48 | //If Invalid Attempts will exceed the 3 then 49 | void callExit(){ 50 | system("cls"); 51 | printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); 52 | printf("\t\t\t\t\t"); 53 | fflush(stdin); 54 | printf("You are out of the System."); 55 | printf("\n\n"); 56 | printf("\t\t\t\t"); 57 | printf(" Press Enter to Continue Exit Program..."); 58 | getchar(); 59 | exit(0); 60 | } 61 | 62 | 63 | void mainpage(){ 64 | int process=0; 65 | system("cls"); 66 | system("color 0B"); //D E 67 | date(); 68 | cout<=3) 134 | { 135 | 136 | printf("\t\t\t\t\t\t"); 137 | printf("\n"); 138 | printf("\t\t\t\t"); 139 | printf(" No permission to enter the system!" ); 140 | getchar(); 141 | callExit(); 142 | getchar(); 143 | 144 | } 145 | } //END OF ELSE 146 | } 147 | while(true==1); 148 | } 149 | 150 | 151 | 152 | void adminlogin(){ 153 | int opt; 154 | menu: 155 | cout<<"\n\t\t\t\t\t\tWELCOME ADMIN"< Check Rooms"< Check Libary"< Check Employees"< Check Contact Book"< Check Canteen"<>opt; 163 | switch(opt){ 164 | case 1:{ 165 | system("cls"); 166 | Booking bookings; 167 | bookings.BookingMenu(); 168 | goto menu; 169 | break; 170 | } 171 | case 2:{ 172 | system("cls"); 173 | AdminLibarymenu(); 174 | break; 175 | } 176 | case 3:{ 177 | system("cls"); 178 | employ e; 179 | e.Employmain(); 180 | break; 181 | } 182 | case 4:{ 183 | system("cls"); 184 | ContactBook c1; 185 | c1.contactBookmenu(); 186 | break; 187 | } 188 | case 5:{ 189 | system("cls"); 190 | Canteen c2; 191 | c2.admin(); 192 | break; 193 | } 194 | default: 195 | cout << "Invalid choice. Enter again.\n\n"; 196 | break; 197 | } 198 | } 199 | 200 | void paybill(){ 201 | int Taxis = 550; 202 | int days, nights, total,cardno,code,opt,recivedamount,balance; 203 | string name; 204 | cout<<"Enter Your Name : "; 205 | cin>>name; 206 | cout<<"\n\t\t\t\t\t\tEnter how many day's you Stay : "; 207 | cin>>days; 208 | cout<<"\n\t\t\t\t\t\tEnter how many nights's you Stay : "; 209 | cin>>nights; 210 | total = (days+nights)*3000+Taxis; 211 | cout<<"\n\t\t\t\t\t\tYou Total Payment : "<>cardno; 217 | cout<<"Enter code : "; 218 | cin>>code; 219 | cout<<"Thank For "<>recivedamount; 225 | if(recivedamount < total){ 226 | cout<<"Please Enter the complete amount !!"<= total){ 230 | balance = total - recivedamount; 231 | if(balance < 0 ){ 232 | balance = -1 * (balance); 233 | cout<<"Thank For "< Check Room Booking"< Goto Canteen"< Goto Libary"< Check Contact Book"< Recive Payment"<>opt; 253 | switch(opt){ 254 | case 1:{ 255 | system("cls"); 256 | Booking bookings; 257 | bookings.BookingMenu(); 258 | break; 259 | } 260 | case 2:{ 261 | system("cls"); 262 | Canteen c2; 263 | c2.customer(); 264 | break; 265 | } 266 | case 3:{ 267 | system("cls"); 268 | main_menu(); 269 | break; 270 | } 271 | case 4:{ 272 | system("cls"); 273 | ContactBook c1; 274 | c1.contactBookmenu(); 275 | break; 276 | } 277 | case 5:{ 278 | system("cls"); 279 | paybill(); 280 | break; 281 | } 282 | default: 283 | cout << "Invalid choice. Enter again.\n\n"; 284 | break; 285 | } 286 | } 287 | 288 | 289 | void studentlogin(){ 290 | int opt; 291 | 292 | cout<<"\n\t\t\t\t\t\tWELCOME STUDENT"< Goto Canteen"< Goto Libary"< Check Contact Book"< Recive Payment"<>opt; 299 | switch(opt){ 300 | case 1:{ 301 | system("cls"); 302 | Canteen c2; 303 | c2.customer(); 304 | break; 305 | } 306 | case 2:{ 307 | system("cls"); 308 | main_menu(); 309 | break; 310 | } 311 | case 3:{ 312 | system("cls"); 313 | ContactBook c1; 314 | c1.contactBookmenu(); 315 | break; 316 | } 317 | case 4:{ 318 | system("cls"); 319 | paybill(); 320 | break; 321 | } 322 | default: 323 | cout << "Invalid choice. Enter again.\n\n"; 324 | break; 325 | } 326 | } 327 | 328 | 329 | 330 | void Mainmenu(){ 331 | int opt; 332 | cout<<"\n\t\t\t\t\t\t1-> Admin "< Receptionist"< Student"<>opt; 337 | switch(opt){ 338 | case 1:{ 339 | system("cls"); 340 | adminlogin(); 341 | break; 342 | } 343 | case 2:{ 344 | system("cls"); 345 | Receptionistlogin(); 346 | break; 347 | } 348 | case 3:{ 349 | system("cls"); 350 | studentlogin(); 351 | break; 352 | } 353 | default: 354 | cout << "Invalid choice. Enter again.\n\n"; 355 | break; 356 | } 357 | } 358 | 359 | int main() { 360 | start_lib=initialize_lib(start_lib); 361 | mainpage(); 362 | system("cls"); 363 | Mainmenu(); 364 | 365 | return 0; 366 | } 367 | -------------------------------------------------------------------------------- /DSA PROJECT/Hostel Management System/Booking.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | //This file is of booking class that book a room for admin, customer, employees of hostel 8 | //which haveing Circular Doubly Linked List & also haveing try throw & catch functions 9 | // this class haveing 3 floors & 9 rooms in each floor (48 rooms). 10 | 11 | //Concepts of Circular Doubly Linked List 12 | //Start Structure of Circular Doubly Linked List 13 | struct NodE{ 14 | int NUMBER = 1; 15 | int fill = 0; 16 | char CUS_NAMES[3][10]; 17 | NodE *NXT; 18 | NodE *PREVIOUS; 19 | }; 20 | 21 | //Start of booking class 22 | class Booking{ 23 | public: 24 | NodE *TITLE[3]; 25 | NodE *WORDS; 26 | //constructor of booking class 27 | Booking(){ 28 | for (int x = 0; x < 3; x++) 29 | TITLE[x] = NULL; 30 | } 31 | // create function of duobly linked list & booking of rooms in hostel that 32 | // haveing 3 floors & 9 rooms in each floor (48 rooms) 33 | void create(){ 34 | for (int x = 0; x < 3; x++){ 35 | for (int y = 0; y < 9; y++){ 36 | NodE *B = new NodE; 37 | B->NXT = NULL; 38 | B->PREVIOUS = NULL; 39 | if (TITLE[x] == NULL){ 40 | TITLE[x] = B; 41 | B->NUMBER = 1; 42 | } 43 | else{ 44 | NodE *WORDS = TITLE[x]; 45 | while (WORDS->NXT != NULL){ 46 | WORDS = WORDS->NXT; 47 | } 48 | if (y == 3 || y == 5 || y == 7 || y == 8){ 49 | WORDS->NUMBER = 3; 50 | } 51 | if (y == 2 || y == 4 || y == 6){ 52 | WORDS->NUMBER = 2; 53 | } 54 | WORDS->NXT = B; 55 | B->PREVIOUS = WORDS; 56 | } 57 | } 58 | } 59 | } 60 | //this function display the list in matrix (table) from with room status 61 | void display(){ 62 | int y = 0, z = 0, w = 0; 63 | for (int x = 0; x < 48; x++){ 64 | cout << "~~"; 65 | } 66 | cout << "\n "; 67 | for (int x = 1; x < 4; x++){ 68 | cout << "| Floor number : "<< x << " \t\t"; 69 | } 70 | cout << "|\n" ; 71 | for (int x = 0; x < 48; x++){ 72 | cout << "~~"; 73 | } 74 | WORDS = TITLE[y]; 75 | NodE *s = TITLE[y + 1]; 76 | NodE *t = TITLE[y + 2]; 77 | cout << "\n "; 78 | while (WORDS != NULL){ 79 | if (WORDS->fill != WORDS->NUMBER && WORDS->NUMBER != 0){ 80 | y++; 81 | cout << "| Room no : "<< y; 82 | cout << "->Vacant cots->"<< WORDS->NUMBER; 83 | } 84 | else{ 85 | y++; 86 | cout << "| Room no : "<< y; 87 | cout << "->Not Vacant"; 88 | } 89 | if (s->fill != s->NUMBER && s->NUMBER != 0){ 90 | z++; 91 | cout << "\t | Room no : "<< y; 92 | cout << "->Vacant cots->"<< s->NUMBER; 93 | } 94 | else{ 95 | z++; 96 | cout << " \t | Room no : "<< y; 97 | cout << "->Present "; 98 | } 99 | if (t->fill != t->NUMBER && t->NUMBER != 0){ 100 | w++; 101 | cout << "\t | Room no : "<< y; 102 | cout << "->Vacant cots->"<< t->NUMBER << "| "; 103 | } 104 | else{ 105 | w++; 106 | cout << "\t | Room no : "<< y; 107 | cout << "->Not Vacant "<< " | "; 108 | } 109 | cout << " \n "; 110 | for (int x = 0; x < 48; x++){ 111 | cout << "--" ; 112 | } 113 | cout << "\n "; 114 | WORDS = WORDS->NXT; 115 | s = s->NXT; 116 | t = t->NXT; 117 | } 118 | } 119 | //This function that book a room fro admin, student, employees 120 | void booking(int people){ 121 | int fl, rom; 122 | cout << "\n Enter the floor number : "; 123 | cin >> fl; 124 | 125 | try{ 126 | if (fl < 0 || fl > 4){ 127 | throw(fl); 128 | } 129 | WORDS = TITLE[fl - 1]; 130 | cout << "\n Enter the room number : "; 131 | cin >> rom; 132 | try{ 133 | if (rom < 0 || rom > 10){ 134 | throw(rom); 135 | } 136 | else{ 137 | int x = 1; 138 | while (x < rom){ 139 | WORDS = WORDS->NXT; 140 | x++; 141 | } 142 | if (WORDS->NUMBER >= people){ 143 | cout << "\n Room is vacant you can apply for this Room "<fill - 1 <= WORDS->NUMBER){ 146 | cout << "\n Enter name "<< WORDS -> fill + 1 << " : "; 147 | cin >> WORDS->CUS_NAMES[WORDS->fill]; 148 | count++; 149 | WORDS->fill++; 150 | if (count >= people){ 151 | break; 152 | } 153 | } 154 | WORDS->NUMBER = WORDS->NUMBER - people; 155 | } 156 | 157 | else{ 158 | cout << "\n Room is not vacant... SORRY !!!"; 159 | } 160 | } 161 | } 162 | catch (int r){ 163 | cout << "\n Invalid Room number : "<< r; 164 | } 165 | } 166 | 167 | catch (int r){ 168 | cout << " \n Invalid Floor number : " << r; 169 | } 170 | } 171 | //This function will cancelled the booked room of any person 172 | void cancelled(int check){ 173 | char checking_namess[10]; 174 | int fg = 0; 175 | int rms, x = 1; 176 | try{ 177 | if (check < 0 || check > 4){ 178 | throw(check); 179 | } 180 | else{ 181 | cout << " Enter the room no : "; 182 | cin >> rms; 183 | try{ 184 | if (rms < 0 || rms > 10){ 185 | throw(rms); 186 | } 187 | else{ 188 | cout << " Enter the name to be delete :"; 189 | cin >> checking_namess; 190 | WORDS = TITLE[check - 1]; 191 | while (x < rms){ 192 | WORDS = WORDS->NXT; 193 | x++; 194 | } 195 | x = 0; 196 | while (x < 3){ 197 | if (!strcmp(checking_namess, WORDS -> CUS_NAMES[x])){ 198 | fg = 1; 199 | break; 200 | x = 0; 201 | } 202 | else 203 | x++; 204 | } 205 | if (fg == 1 && WORDS->fill != 0){ 206 | cout << "\n Record deleted : "<< WORDS -> CUS_NAMES[x]; 207 | WORDS->CUS_NAMES[x][0] ='A'; 208 | WORDS->CUS_NAMES[x][1] ='\0'; 209 | WORDS->fill--; 210 | WORDS->NUMBER++; 211 | } 212 | else{ 213 | cout << "\n Record not present "; 214 | } 215 | } 216 | } 217 | 218 | catch (int r){ 219 | cout << "\n Invalid room number : " << r; 220 | } 221 | } 222 | } 223 | catch (int r){ 224 | cout << " \n Floor dosn't exist : " << r; 225 | } 226 | } 227 | //This function will modyfy the data & can change the room & floor of any booked room 228 | void modify(int check){ 229 | char checking_namess[10]; 230 | int rms, x = 1; 231 | try{ 232 | if (check < 0 || check > 4){ 233 | throw(check); 234 | } 235 | else{ 236 | cout << " Enter the Room number : "; 237 | cin >> rms; 238 | try{ 239 | if (rms < 0 || rms > 10){ 240 | throw(rms); 241 | } 242 | else{ 243 | cout << " Enter the name to be updated :"; 244 | cin >> checking_namess; 245 | WORDS = TITLE[check - 1]; 246 | while (x < rms){ 247 | WORDS = WORDS->NXT; 248 | x++; 249 | } 250 | x = 0; 251 | while (x < 3){ 252 | if (!strcmp(checking_namess, WORDS -> CUS_NAMES[x])){ 253 | cout << "\n Enter updated name : " ; 254 | cin >> WORDS->CUS_NAMES[x]; 255 | break; 256 | } 257 | else 258 | x++; 259 | } 260 | if (x >= 3) 261 | cout << "Record not found "<CUS_NAMES[x]; 264 | } 265 | } 266 | } 267 | catch (int r){ 268 | cout << "\n Invalid room number : "<< r< Book a room for Student \n 2-> Book a room for Admin \n 3-> Book a room for Staff \n 4-> Display the Current Status of Rooms \n 5-> Cancel a Booking\n 6-> Modify"<< endl; 287 | cout << " Enter your choice : " ; 288 | cin >> opt; 289 | cout<> checking_floors; 329 | bookings.cancelled(checking_floors); 330 | break; 331 | } 332 | case 6: 333 | { 334 | system ("CLS"); 335 | cout << " Enter Floor number : "; 336 | cin >> checking_floors; 337 | bookings.modify(checking_floors); 338 | break; 339 | } 340 | 341 | default: 342 | cout << "\n Invalid choice "; 343 | } 344 | cout << "\n Do you want to continue(Y / N) "; 345 | cin >> channels; 346 | system ("CLS"); 347 | } while (channels =='Y'|| channels =='y'); 348 | } 349 | }; 350 | //End of booking class 351 | -------------------------------------------------------------------------------- /DSA PROJECT/Hostel Management System/Libary Student.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | using namespace std; 9 | 10 | //This file is of book class of libary for function of student which haveing two singly Linked List 11 | //This file contacts the File Handling, typedef also this file haveing queue 12 | //one is for book List 13 | //secound of student List 14 | 15 | //Concepts of singly Linked List 16 | //Start Structure of singly Linked List 17 | struct book{ 18 | char name[30]; 19 | char author[30]; 20 | int id; 21 | struct book *next; 22 | }; 23 | 24 | //Start Structure of singly Linked List to store the data for student who ssue the book 25 | struct student{ 26 | char name[30]; 27 | char email[20]; 28 | char book[20]; 29 | char a[30]; 30 | int id; 31 | struct student *next; 32 | }; 33 | 34 | //All function decleration 35 | struct book *start_lib=NULL; 36 | struct student *start=NULL; 37 | struct book *initialize_lib(struct book *); 38 | struct student *book_issue(struct student *); 39 | struct student *book_return(struct student *); 40 | struct book *diplay_lib(struct book *); 41 | struct book *delete_book(int); 42 | struct book *add_book(char [],char [],int); 43 | void display(struct student *); 44 | void greetings(); 45 | void main_menu(); 46 | 47 | //Main menu of this class that haveing the functions of libary class 48 | void main_menu(){ 49 | int choice; 50 | do{ 51 | cout<<"\n\n"; 52 | cout<<"\n\t\t\t*************************************************\n"; 53 | cout<<"\n\t\t\t\t MAIN MENU: "; 54 | cout<<"\n\t\t\t\t 1.ISSUE OF BOOKS "; 55 | cout<<"\n\t\t\t\t 2.RETURN OF BOOKS "; 56 | cout<<"\n\t\t\t\t 3.DISPLAY STUDENT DETAILS "; 57 | cout<<"\n\t\t\t\t 4.EXIT\n "; 58 | cout<<"\n\t\t\t*************************************************\n"; 59 | cout<<"\n\t\t\t\t Enter your choice: "; 60 | cin>>choice; 61 | switch(choice){ 62 | case 1:{ 63 | start=book_issue(start); 64 | break; 65 | } 66 | case 2:{ 67 | system("cls"); 68 | start=book_return(start); 69 | break; 70 | } 71 | case 3:{ 72 | system("cls"); 73 | display(start); 74 | break; 75 | } 76 | case 4:{ 77 | exit(1); 78 | } 79 | default:{ 80 | cout<<"\n\t\t\t\t ...Invalid Option!...\n"; 81 | cout<<"\n\t\t\t\t Press any key to try again: "; 82 | getch(); 83 | } 84 | } 85 | }while(choice!=4); 86 | } 87 | 88 | 89 | struct book *initialize_lib(struct book *start){ 90 | 91 | struct book *ptr,*new_book1,*new_book2,*new_book3,*new_book4,*new_book5; 92 | new_book1=(struct book *)malloc(sizeof(struct book)); 93 | new_book1->next=NULL; 94 | start_lib=new_book1; 95 | strcpy(new_book1->name,"C++ All-in-One "); 96 | strcpy(new_book1->author,"Khaled Dummies"); 97 | new_book1->id=101; 98 | ptr=new_book1; 99 | 100 | new_book2=(struct book*)malloc(sizeof(struct book)); 101 | new_book2->next=NULL; 102 | strcpy(new_book2->name,"Let Us C"); 103 | strcpy(new_book2->author,"Harper Lee"); 104 | new_book2->id=102; 105 | ptr->next=new_book2; 106 | ptr=new_book2; 107 | 108 | new_book3=(struct book*)malloc(sizeof(struct book)); 109 | new_book3->next=NULL; 110 | strcpy(new_book3->name,"Let Us C++"); 111 | strcpy(new_book3->author,"Paulo Coelho"); 112 | new_book3->id=103; 113 | ptr->next=new_book3; 114 | ptr=new_book3; 115 | 116 | new_book4=(struct book*)malloc(sizeof(struct book)); 117 | new_book4->next=NULL; 118 | strcpy(new_book4->name,"Python And Prejudice"); 119 | strcpy(new_book4->author,"Jane Austen"); 120 | new_book4->id=104; 121 | ptr->next=new_book4; 122 | ptr=new_book4; 123 | 124 | new_book5=(struct book*)malloc(sizeof(struct book)); 125 | new_book5->next=NULL; 126 | strcpy(new_book5->name,"A Tale Of Two Cities"); 127 | strcpy(new_book5->author,"Charles Dickens"); 128 | new_book5->id=105; 129 | ptr->next=new_book5; 130 | 131 | return start_lib; 132 | } 133 | 134 | struct student *book_issue(struct student *start){ 135 | struct book *ptr; 136 | struct student *ptr2,*new_student; 137 | int i=1,id,flag=0; 138 | if(start_lib==NULL){ 139 | cout<<"\n\t\t\t\t No books left in the library to issue!\n\t\t\t\t Sorry for the inconvenience!\n"; 140 | }else{ 141 | system("cls"); 142 | ptr=start_lib; 143 | cout<<"\n\t*************** Books Available: ****************\n"; 144 | while(ptr!=NULL){ 145 | cout<<"\n\t_________________________________________________\n"; 146 | cout<<"\n\t Book : "<name; 148 | cout<<"\n\t Name of Author: "<author; 149 | cout<<"\n\t Book ID: "<id; 150 | cout<<"\n\t_________________________________________________\n"; 151 | ptr=ptr->next; 152 | i++; 153 | } 154 | cout<<"\n\n\t Enter the Book ID: "; 155 | cin>>id; 156 | ptr=start_lib; 157 | while(ptr!=NULL){ 158 | if(ptr->id==id){ 159 | flag=1; 160 | break; 161 | } 162 | ptr=ptr->next; 163 | } 164 | if(flag==1){ 165 | ptr=start_lib; 166 | while(ptr->id!=id){ 167 | ptr=ptr->next; 168 | } 169 | new_student=(struct student *)malloc(sizeof(struct student)); 170 | cout<<"\n\t Enter Student Details \n "; 171 | cout<<"\n\t Enter your Name : "; 172 | cin>>new_student->name; 173 | cout<<"\n\t Enter your Email : "; 174 | cin>>new_student->email; 175 | strcpy(new_student->book,ptr->name); 176 | strcpy(new_student->a,ptr->author); 177 | new_student->id=ptr->id; 178 | new_student->next=NULL; 179 | cout<<"\n\t Issue of Book done successfully! ID : "<id<next!=NULL){ 186 | ptr2=ptr2->next; 187 | } 188 | ptr2->next=new_student; 189 | } 190 | start_lib=delete_book(new_student->id); 191 | cout<<"\n\n\t Press any key to go to the main menu: "; 192 | getch(); 193 | system("cls"); 194 | }else{ 195 | cout<<"\n\t\t ...Invalid Option!...\n"; 196 | cout<<"\n\t\t Press any key to try again: "; 197 | getch(); 198 | system("cls"); 199 | } 200 | } 201 | return start; 202 | } 203 | 204 | struct student *book_return(struct student *start){ 205 | struct student *ptr,*preptr; 206 | char bookname[30],authorname[30]; 207 | int flag=0,id,identity,c=0,d=1; 208 | cout<<"\n\n\t*************** Books Submission: ****************\n"; 209 | cout<<"\n\n\t Enter your Book ID : "; 210 | cin>>identity; 211 | ptr=start; 212 | while(ptr!=NULL){ 213 | if(ptr->id==identity){ 214 | flag=1; 215 | break; 216 | } 217 | ptr=ptr->next; 218 | } 219 | if(flag==1){ 220 | ptr=start; 221 | while(ptr!=NULL){ 222 | c++; 223 | ptr=ptr->next; 224 | } 225 | ptr=start; 226 | while(ptr->id!=identity){ 227 | d++; 228 | ptr=ptr->next; 229 | } 230 | ptr=start; 231 | if( d==1 ){ 232 | cout<<"\n\t_________________________________________________\n"; 233 | cout<<"\n\t Student Name: "<name; 234 | cout<<"\n\t Student Email: "<email; 235 | cout<<"\n\t Name of Book Issued: "<book; 236 | cout<<"\n\t_________________________________________________\n"; 237 | cout<<"\n\n\t Return of Book ID done successfully!\n",identity; 238 | cout<<"\n\n\t*************************************************\n"; 239 | strcpy(bookname,start->book); 240 | strcpy(authorname,start->a); 241 | id=start->id; 242 | start=start->next; 243 | free(ptr); 244 | add_book(bookname,authorname,id); 245 | }else{ 246 | ptr=start; 247 | while(ptr->id!=identity){ 248 | preptr=ptr; 249 | ptr=ptr->next; 250 | } 251 | cout<<"\n\t_________________________________________________\n"; 252 | cout<<"\n\t Student Name: "<name; 253 | cout<<"\n\t Student Email: "<email; 254 | cout<<"\n\t Name of Book Issued: "<book; 255 | cout<<"\n\t Book ID: "<id; 256 | cout<<"\n\t_________________________________________________\n"; 257 | strcpy(bookname,ptr->book); 258 | strcpy(authorname,ptr->a); 259 | id=ptr->id; 260 | preptr->next=ptr->next; 261 | free(ptr); 262 | add_book(bookname,authorname,id); 263 | } 264 | cout<<"\n\t Thank you! "; 265 | cout<<"\n\n\t Press any key to go to the main menu: "; 266 | getch(); 267 | system("cls"); 268 | }else{ 269 | cout<<"\n\tSorry the book doesn't exist! Please Recheck the entered ID"; 270 | cout<<"\n\t\t\t\t Press any key to try again: "; 271 | getch(); 272 | system("cls"); 273 | } 274 | return start; 275 | } 276 | 277 | //concept of Merge Sort 278 | //Start Merge Sort 279 | void merge(int arr[], int p, int q, int r) { 280 | int n1 = q - p + 1; 281 | int n2 = r - q; 282 | int L[n1], M[n2]; 283 | int i, j, k; 284 | 285 | for (int i = 0; i < n1; i++) 286 | L[i] = arr[p + i]; 287 | for (int j = 0; j < n2; j++) 288 | M[j] = arr[q + 1 + j]; 289 | 290 | i = 0; 291 | j = 0; 292 | k = p; 293 | 294 | while (i < n1 && j < n2) { 295 | if (L[i] <= M[j]) { 296 | arr[k] = L[i]; 297 | i++; 298 | } else { 299 | arr[k] = M[j]; 300 | j++; 301 | } 302 | k++; 303 | } 304 | 305 | while (i < n1) { 306 | arr[k] = L[i]; 307 | i++; 308 | k++; 309 | } 310 | 311 | while (j < n2) { 312 | arr[k] = M[j]; 313 | j++; 314 | k++; 315 | } 316 | } 317 | //End Merge Sort 318 | 319 | void display(struct student *start){ 320 | struct student *ptr; 321 | ptr=start; 322 | while(ptr!=NULL){ 323 | cout<<"\n\t************* Details of Students: **************\n"; 324 | cout<<"\n\t_________________________________________________\n"; 325 | cout<<"\n\t\t Student Name: %s",ptr->name; 326 | cout<<"\n\t\t Student Email: %s",ptr->email; 327 | cout<<"\n\t\t Name of Book Issued: %s",ptr->book; 328 | cout<<"\n\t\t Book ID: %d",ptr->id; 329 | cout<<"\n\t_________________________________________________\n"; 330 | cout<<"\n\n\t*************************************************\n"; 331 | ptr=ptr->next; 332 | } 333 | cout<<"\n\n\t Press any key to go to the main menu: "; 334 | getch(); 335 | system("cls"); 336 | } 337 | 338 | struct book *delete_book(int id){ 339 | struct book *ptr,*preptr; 340 | int c=0; 341 | ptr=start_lib; 342 | while(ptr!=NULL){ 343 | c++; 344 | ptr=ptr->next; 345 | } 346 | if(c==1){ 347 | ptr=start_lib; 348 | start_lib=NULL; 349 | free(ptr); 350 | }else if(start_lib->id==id){ 351 | ptr=start_lib; 352 | start_lib=start_lib->next; 353 | free(ptr); 354 | }else{ 355 | ptr=start_lib; 356 | while(ptr->id!=id){ 357 | preptr=ptr; 358 | ptr=ptr->next; 359 | } 360 | preptr->next=ptr->next; 361 | free(ptr); 362 | } 363 | return start_lib; 364 | } 365 | 366 | struct book *add_book(char bookname[30],char authorname[30],int id){ 367 | struct book *ptr,*new_book; 368 | new_book=(struct book *)malloc(sizeof(struct book)); 369 | strcpy(new_book->name,bookname); 370 | strcpy(new_book->author,authorname); 371 | new_book->id=id; 372 | new_book->next=NULL; 373 | if(start_lib==NULL){ 374 | start_lib=new_book; 375 | }else{ 376 | ptr=start_lib; 377 | while(ptr->next!=NULL){ 378 | ptr=ptr->next; 379 | } 380 | ptr->next=new_book; 381 | } 382 | return start_lib; 383 | } 384 | -------------------------------------------------------------------------------- /DSA PROJECT/Hostel Management System/libary Admin.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | //This file is of book class of libary for function of admin which haveing singly Linked List 7 | //This file contacts the File Handling, typedef also this file haveing queue 8 | 9 | 10 | //Start Of Book class 11 | class Book{ 12 | public: 13 | string title; 14 | string author; 15 | string publisher; 16 | int year; 17 | string isbn; 18 | Book* next; 19 | Book(string, string, string, int, string, Book*); 20 | void AdminLibarymenu(); 21 | }; 22 | //End Of Book class 23 | 24 | 25 | //Start of class QUEUE 26 | class QUEUE: public Book{ 27 | public: 28 | int queue[5]; //queue 29 | int front = -1, rear = -1, n=5; //frontindex & rearindex is inclized by -1 and n is the size of queue 30 | 31 | //Funtion to enter new vlaue in queue 32 | void EQueue(int val) { 33 | if ((front == 0 && rear == n-1) || (front == rear+1)) { //Condition to check queue is full or not 34 | cout<<"Queue Overflow \n"; 35 | return; 36 | } 37 | if (front == -1) { // if front index is -1 so it means that queue is empty so before user entry its number frontindex & rearindex will become 0 38 | front = 0; 39 | rear = 0; 40 | } 41 | else // if queue is not full 42 | { 43 | if (rear == n - 1) //if rearindex is full so this condition is true & rearindex will become zero to make our queue circular 44 | rear = 0; 45 | else 46 | rear = rear + 1; //this will increment of one in rearindex 47 | } 48 | queue[rear] = val ; //assigend the value of user to rearindex 49 | } 50 | 51 | //Funtion to delete fisrt vlaue of queue 52 | void DeQueue() { 53 | if (front == -1) { //Condition to check queue is full or not 54 | cout<<"Queue Underflow\n"; 55 | return ; 56 | } 57 | cout<<"Element deleted from queue is : "<> temp; 138 | stream.ignore(500, delimiter); 139 | num= temp; 140 | } 141 | //All function decleration 142 | void readFile(bookPtr &root); 143 | void insert (bookPtr &root); 144 | void delTitle(bookPtr &root); 145 | bookPtr locateNode(bookPtr temp, string titl); 146 | void delIsbn(bookPtr &root); 147 | bookPtr locateNodeIsbn(bookPtr temp, string isb); 148 | void searchIsbn(bookPtr temp); 149 | void printList(bookPtr temp); 150 | void printAuthor(bookPtr temp); 151 | void saveFile(bookPtr temp); 152 | int countNodes(bookPtr temp); 153 | void AdminLibarymenu(); 154 | 155 | void readFile(bookPtr &root){ 156 | int numBooks, yea; 157 | string titl, aut, pub, isb; 158 | ifstream infile ("books.txt", ios::in); 159 | infile >> numBooks; 160 | infile.ignore(500,'\n'); 161 | for (int count = 0; count < numBooks; count++){ 162 | getline(infile, titl, '\n'); 163 | getline(infile, aut, '\n'); 164 | getline(infile, pub, '\n'); 165 | getline(infile,yea, '\n'); 166 | getline(infile, isb, '\n'); 167 | 168 | root = new Book(titl, aut, pub, yea, isb, root); 169 | } 170 | } 171 | 172 | void insert (bookPtr &root){ 173 | string titl, aut, pub, isb; 174 | int yea; 175 | cout<<"\t\t\tYou Are Going To Add New Book Please Enter Book Detais"<next; 204 | else{ 205 | bookPtr q = root; 206 | while (q->next != p) 207 | q = q->next; 208 | q->next = p->next; 209 | } 210 | delete p; 211 | } 212 | 213 | bookPtr locateNode(bookPtr temp, string titl){ 214 | while (temp != NULL){ 215 | if (temp->title == titl){ 216 | return temp; 217 | } 218 | temp = temp->next; 219 | } 220 | return NULL; 221 | } 222 | 223 | void delIsbn(bookPtr &root){ 224 | string isb; 225 | cout<<"\t\t\tYou Are Going To Remove a Book"<next; 236 | else{ 237 | bookPtr q = root; 238 | while (q->next != p) 239 | q = q->next; 240 | q->next = p->next; 241 | } 242 | delete p; 243 | } 244 | 245 | bookPtr locateNodeIsbn(bookPtr temp, string isb){ 246 | while (temp != NULL){ 247 | if (temp->isbn == isb){ 248 | return temp; 249 | } 250 | temp = temp->next; 251 | } 252 | return NULL; 253 | } 254 | 255 | void searchIsbn(bookPtr temp){ 256 | string isb; 257 | cout<<"\t\t\tYou Are Going To Sreach a Book Please Enter ISBN Number of that Book to See Deatils"<isbn){ 264 | cout <<"Title : "<title << "\n"; 265 | cout <<"Author : "<author << "\n"; 266 | cout <<"Publisher : "<publisher << "\n"; 267 | cout <<"Year : "<year << "\n"; 268 | cout <<"ISBN Number : "<isbn << "\n\n"; 269 | } 270 | temp = temp->next; 271 | } 272 | cout << "\n"; 273 | } 274 | 275 | void printList(bookPtr temp){ 276 | cout<<"\t\t\tBook Details "<title << "\n"; 279 | cout <<"Author : "<< temp->author << "\n"; 280 | cout <<"Publisher : "<publisher << "\n"; 281 | cout <<"Year : "<< temp->year << "\n"; 282 | cout <<"ISBN Number : "<< temp->isbn << "\n\n"; 283 | temp = temp->next; 284 | } 285 | cout << "\n"; 286 | } 287 | 288 | void printAuthor(bookPtr temp){ 289 | string aut; 290 | cout<<"\t\t\tBook Details "<author == aut){ 297 | cout <<"Title : "<title << "\n"; 298 | cout <<"Author : "<< temp->author << "\n"; 299 | cout <<"Publisher : "<< temp->publisher << "\n"; 300 | cout <<"Year : "<< temp->year << "\n"; 301 | cout <<"ISBN Number : "<< temp->isbn << "\n\n"; 302 | } 303 | temp = temp->next; 304 | } 305 | cout << "\n"; 306 | } 307 | 308 | void saveFile(bookPtr temp){ 309 | int count = countNodes(temp); 310 | ofstream outFile("saved.txt",ios::out); 311 | outFile << count << "\n"; 312 | while (temp != NULL){ 313 | outFile << temp->title << "\n"; 314 | outFile << temp->author << "\n"; 315 | outFile << temp->publisher << "\n"; 316 | outFile << temp->year << "\n"; 317 | outFile << temp->isbn << "\n"; 318 | temp = temp->next; 319 | } 320 | cout << "\n"; 321 | } 322 | 323 | //Function that count nodes 324 | int countNodes(bookPtr temp){ 325 | int countB = 0; 326 | while (temp != NULL){ 327 | countB++; 328 | temp = temp->next; 329 | } 330 | return countB; 331 | } 332 | 333 | //Concept of Quick Sort 334 | //Start Qucik Sort 335 | 336 | // Function of Swap that swap for sorting 337 | void swap(int *a, int *b) { 338 | int t = *a; 339 | *a = *b; 340 | *b = t; 341 | } 342 | //print data after sorting 343 | void printArray(int array[], int size) { 344 | int i; 345 | for (i = 0; i < size; i++) 346 | cout << array[i] << " "; 347 | cout << endl; 348 | } 349 | // Function that do partion in array for sorting 350 | int partition(int array[], int low, int high) { 351 | int pivot = array[high]; 352 | int i = (low - 1); 353 | for (int j = low; j < high; j++) { 354 | if (array[j] <= pivot) { 355 | i++; 356 | swap(&array[i], &array[j]); 357 | } 358 | } 359 | swap(&array[i + 1], &array[high]); 360 | return (i + 1); 361 | } 362 | 363 | //Concept of Recursion 364 | //function Quick Sort 365 | void quickSort(int array[], int low, int high) { 366 | if (low < high) { 367 | int pi = partition(array, low, high); 368 | quickSort(array, low, pi - 1); 369 | quickSort(array, pi + 1, high); 370 | } 371 | } 372 | //End Qucik Sort 373 | 374 | // The Admin Menu for Libary class functions 375 | void AdminLibarymenu(){ 376 | int choice; 377 | bookPtr root = NULL; 378 | readFile(root); 379 | 380 | do{ 381 | cout << "\t\t<<=========================>>"; 382 | cout << "\n\t\t>>LIBRARY MANAGEMENT SYSTEM<<"; 383 | cout << "\n\t\t<<=========================>>"; 384 | cout << "\n\nMenu: Select your option\n\n"; 385 | cout << "(1) Add a book to the list\n"; 386 | cout << "(2) Delete a book based on Title\n"; 387 | cout << "(3) Delete a book based on ISBN\n"; 388 | cout << "(4) Search for a book by ISBN.\n"; 389 | cout << "(5) List all books.\n"; 390 | cout << "(6) Search all books by an author.\n"; 391 | cout << "(7) Quit.\n\n"; 392 | cout << "Enter your choice ---> "; 393 | cin >> choice; 394 | 395 | if (1 <= choice && choice <= 6) 396 | { 397 | switch (choice) 398 | { 399 | case 1: 400 | system("cls"); 401 | insert(root); 402 | break; 403 | case 2: 404 | system("cls"); 405 | delTitle(root); 406 | break; 407 | case 3: 408 | system("cls"); 409 | delIsbn(root); 410 | break; 411 | case 4: 412 | system("cls"); 413 | searchIsbn(root); 414 | break; 415 | case 5: 416 | system("cls"); 417 | printList(root); 418 | break; 419 | case 6: 420 | system("cls"); 421 | printAuthor(root); 422 | break; 423 | default: 424 | system("cls"); 425 | cout << "Invalid choice. Enter again.\n\n"; 426 | break; 427 | } 428 | } 429 | } 430 | while (choice != 7); 431 | saveFile(root); 432 | } 433 | -------------------------------------------------------------------------------- /DSA PROJECT/Hostel Management System/Canteen.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | using namespace std; 9 | 10 | //This file is of canteen class which haveing two Doubly Linked List 11 | //one is for Admin List 12 | //secound of customer List 13 | 14 | //Concepts of Doubly Linked List 15 | 16 | //Start Structure of Doubly Linked List 17 | struct NODE{ 18 | char foodname[50]; 19 | int quantity; 20 | float price; 21 | int data; 22 | struct NODE *prev; 23 | struct NODE *next; 24 | }; 25 | //End Structure of Doubly Linked List 26 | 27 | 28 | //Nodes of Doubly Linked List 29 | struct NODE *headc = NULL,*newnode,*tailc = NULL; 30 | struct NODE *heada = NULL, *taila = NULL; 31 | struct NODE *head_s; 32 | //headc = head of customer 33 | //tailc = tail of customer 34 | //heada = head of Admin 35 | //taila = tail of Admin 36 | 37 | //Start of Function that create a Doubly Linked List of Admin 38 | struct NODE* createadmin(struct NODE *head,int data, char foodname[25], float price){ 39 | newnode = new NODE; 40 | newnode->data = data; 41 | newnode->price = price; 42 | newnode-> quantity = 0; 43 | strcpy(newnode->foodname,foodname); 44 | newnode->next = NULL; 45 | newnode->prev = NULL; 46 | 47 | struct NODE *temp = head; 48 | 49 | if(temp==NULL) //if the list is empty then head contains the data that comes first 50 | heada = taila = newnode; 51 | else{ 52 | while(temp->next!=NULL) 53 | temp=temp->next; 54 | 55 | temp->next=newnode; 56 | newnode->prev = taila; 57 | taila = newnode; 58 | } 59 | return heada; 60 | } 61 | //End of Function that create a Doubly Linked List of Admin 62 | 63 | 64 | //Start of Function that create a Doubly Linked List of Customer 65 | struct NODE* createcustomer(struct NODE *head,int data,int quantity){ 66 | newnode = new NODE; 67 | struct NODE *temp1 = heada; 68 | int flag = 0; 69 | while(temp1!=NULL){ 70 | if(temp1->data==data){ 71 | flag = 1; 72 | break; 73 | } 74 | temp1 = temp1->next; 75 | } 76 | if(flag==1){ //if the list is empty then head contains the data that comes first 77 | newnode->data = data; 78 | newnode->price = quantity*(temp1->price); 79 | newnode-> quantity = quantity; 80 | strcpy(newnode->foodname,temp1->foodname); 81 | newnode->next = NULL; 82 | newnode->prev = NULL; 83 | struct NODE *temp = head; 84 | if(temp==NULL) 85 | headc = tailc = newnode; 86 | else{ 87 | while(temp->next!=NULL) 88 | temp=temp->next; 89 | 90 | temp->next=newnode; 91 | newnode->prev = tailc; 92 | tailc = newnode; 93 | } 94 | } 95 | else{ 96 | cout<<"\n\t\t\t\t\t\t\t This item is not present in the menu! \n"; 97 | } 98 | return headc; 99 | } 100 | //End of Function that create a Doubly Linked List of customer 101 | 102 | 103 | //Start of Canteen Class 104 | class Canteen{ 105 | public: 106 | 107 | // Menu for admin 108 | void adminmenu(){ 109 | cout<quantity==0) 139 | cout<<"\n\t\t\t\t\t\t\t"<data<<" for "<foodname<<" "<price<data<<" for "<foodname<<" "<quantity<<" "<price; 142 | } 143 | temp1 = temp1->next; 144 | } 145 | cout<data!=data){ 155 | temp1 = temp1->next; 156 | } 157 | 158 | newnode->data = data; 159 | newnode->price = quantity*(temp1->price); 160 | newnode-> quantity = quantity; 161 | strcpy(newnode->foodname,temp1->foodname); 162 | newnode->next = NULL; 163 | newnode->prev = NULL; 164 | 165 | struct NODE *temp = head_s; 166 | 167 | if(temp==NULL) 168 | head_s = newnode; 169 | else{ 170 | while(temp->next!=NULL){ 171 | if(temp->data==data){ 172 | flag = 1; 173 | break; 174 | } 175 | temp=temp->next; 176 | } 177 | 178 | if(flag==1){ 179 | temp->quantity += newnode-> quantity; 180 | temp->price += newnode->price; 181 | } 182 | else{ 183 | temp->next=newnode; 184 | } 185 | } 186 | return head_s; 187 | } 188 | // End Funtion that count the total sales of canteen that can admin see 189 | 190 | // Start Funtion that calculates the total sales of canteen that can admin see 191 | void calculatetotsales(){ 192 | struct NODE *temp = headc; 193 | while(temp!=NULL){ 194 | head_s = totalsales(temp->data, temp->quantity); 195 | temp=temp->next; 196 | } 197 | } 198 | // End Funtion that calculates the total sales of canteen that can admin see 199 | 200 | 201 | // Start Funtion that delete the node from any side of list 202 | struct NODE* Delete(int data,struct NODE *head, struct NODE* tail){ 203 | if(head==NULL){ 204 | cout<<"\n\t\t\t\t\t\t\t List is empty\n"; 205 | } 206 | else{ 207 | struct NODE* temp; 208 | if(data == head->data){ 209 | temp = head; 210 | head = head->next; 211 | if (head != NULL) 212 | head->prev = NULL; 213 | free(temp); 214 | } 215 | else if(data==tail->data){ 216 | temp = tail; 217 | tail = tail->prev; 218 | tail->next = NULL; 219 | free(temp); 220 | } 221 | else{ 222 | temp = head; 223 | while(data!=temp->data){ 224 | temp = temp->next; 225 | } 226 | (temp->prev)->next = temp->next; 227 | (temp->next)->prev = temp->prev; 228 | free(temp); 229 | } 230 | } 231 | return head; 232 | } 233 | // Start Funtion that delete the node from any side of list 234 | 235 | //this function delete the data from admin list 236 | int deleteadmin(){ 237 | int num; 238 | 239 | cout<<"\n\t\t\t\t\t\t\t Enter serial no. of the food item which is to be deleted: "; 240 | cin>>num; 241 | 242 | struct NODE* temp= heada; 243 | 244 | while(temp!=NULL){ 245 | if (temp->data == num){ 246 | heada = Delete(num, heada, taila); 247 | return 1; 248 | } 249 | temp=temp->next; 250 | } 251 | return 0; 252 | } 253 | 254 | //this function delete the data from customer list 255 | int deletecustomer(){ 256 | int num; 257 | 258 | cout<<"\n\t\t\t\t\t\t\t Enter serial no. of the food item which is to be deleted: "; 259 | cin>>num; 260 | 261 | struct NODE* temp=headc; 262 | 263 | while(temp!=NULL){ 264 | if (temp->data == num){ 265 | headc = Delete(num, headc, tailc); 266 | return 1; 267 | } 268 | temp=temp->next; 269 | } 270 | return 0; 271 | } 272 | 273 | //This function show the total bill to user 274 | void displaybill(){ 275 | // date(); 276 | displayList(headc); 277 | struct NODE *temp = headc; 278 | float total_price = 0; 279 | while (temp!=NULL){ 280 | total_price +=temp->price; 281 | temp = temp->next; 282 | } 283 | cout<<"\t\t\t\t\t\t\t Total price: "<next!=0){ 293 | temp = temp->next; 294 | free(temp->prev); 295 | } 296 | free(temp); 297 | head = NULL; 298 | } 299 | return head; 300 | } 301 | 302 | //This function that show the menu of admin functions 303 | void admin(){ 304 | int opt; 305 | cout<<"\n\t\t\t\t\t ----------------------------------------------\n"; 306 | cout<<"\t\t\t\t\t\t\t ADMIN SECTION\n"; 307 | cout<<"\t\t\t\t\t ----------------------------------------------\n"; 308 | while(1){ 309 | adminmenu(); 310 | 311 | cin>>opt; 312 | 313 | if(opt==5){ 314 | system("cls"); 315 | break; 316 | } 317 | 318 | switch (opt){ 319 | case 1: 320 | system("cls"); 321 | displayList(head_s); 322 | break; 323 | case 2:{ 324 | system("cls"); 325 | cout<<"\n\t\t\t\t\t\t\t Enter serial no. of the food item: "; 326 | int num,flag = 0; 327 | char name[50]; 328 | float price; 329 | cin>>num; 330 | struct NODE *temp = heada; 331 | while(temp!=NULL){ 332 | if(temp->data==num){ 333 | cout<<"\t\t\t\t\t\t\t Food item with given serial number already exists!!\n\n"; 334 | flag = 1; 335 | break; 336 | } 337 | temp = temp->next; 338 | } 339 | if(flag==1) 340 | break; 341 | 342 | cout<<"\t\t\t\t\t\t\t Enter food item name: "; 343 | cin>>name; 344 | cout<<"\t\t\t\t\t\t\t Enter price: "; 345 | cin>>price; 346 | heada = createadmin(heada, num, name, price); 347 | cout<<"\t\t\t\t\t\t\t New food item added to the list!!\n\n"; 348 | break; 349 | } 350 | case 3:{ 351 | system("cls"); 352 | if(deleteadmin()){ 353 | cout<<"\t\t\t\t\t\t\t ### Updated list of food items menu ###\n"; 354 | displayList(heada); 355 | } 356 | else 357 | cout<<"\n\t\t\t\t\t\t\t Food item with given serial number doesn't exist!\n\n"; 358 | break; 359 | } 360 | case 4:{ 361 | system("cls"); 362 | cout<<"\n\t\t\t\t\t\t\t ### Order menu ###\n"; 363 | displayList(heada); 364 | break; 365 | } 366 | default: 367 | cout<<"\n\t\t\t\t\t\t\t Wrong Input !! PLease choose valid option\n"; 368 | break; 369 | } 370 | } 371 | } 372 | 373 | //This function that show the menu of customer functions 374 | void customer(){ 375 | int flag=0,j=1; 376 | char ch; 377 | cout<<"\n\t\t\t\t\t ----------------------------------------------\n"; 378 | cout<<"\t\t\t\t\t\t\t CUSTOMER SECTION\n"; 379 | cout<<"\t\t\t\t\t ----------------------------------------------\n"; 380 | while(1){ 381 | customermenu(); 382 | int opt; 383 | cin>>opt; 384 | 385 | if(opt==5){ 386 | system("cls"); 387 | break; 388 | } 389 | 390 | switch (opt){ 391 | case 1: 392 | system("cls"); 393 | displayList(heada); 394 | cout<<"\n\t\t\t\t\t\t\t Enter number corresponding to the item you want to order: "; 395 | int n; 396 | cin>>n; 397 | cout<<"\t\t\t\t\t\t\t Enter quantity: "; 398 | int quantity; 399 | cin>>quantity; 400 | headc = createcustomer(headc, n, quantity); 401 | break; 402 | case 2: 403 | system("cls"); 404 | cout<<"\n ### List of ordered items ###\n"; 405 | displayList(headc); 406 | break; 407 | case 3: 408 | system("cls"); 409 | if(deletecustomer()){ 410 | cout<<"\n\t\t\t\t\t\t\t ### Updated list of your ordered food items ###\n"; 411 | displayList(headc); 412 | } 413 | else 414 | cout<<"\n\t\t\t\t\t\t\t Food item with given serial number doesn't exist!!\n"; 415 | break; 416 | case 4: 417 | system("cls"); 418 | calculatetotsales(); 419 | cout<<"\n\t\t\t\t\t\t\t ### Final Bill ###\n"; 420 | displaybill(); 421 | headc = deleteList(headc); 422 | cout<<"\n\t\t\t\t\t\t\t Press any key to return to main menu: \n"; 423 | fflush(stdin); 424 | ch=fgetc(stdin); 425 | flag=1; 426 | break; 427 | 428 | default: 429 | cout<<"\n\t\t\t\t\t\t\t Wrong Input !! PLease choose valid option\n"; 430 | break; 431 | } 432 | if(flag==1) 433 | break; 434 | } 435 | } 436 | //Main Function 437 | void mainnenu(){ 438 | cout<<"\n **************************************************************************\n"; 439 | cout<<" WELCOME TO MAJU HOSTEL CANTEEN\n"; 440 | cout<<" **************************************************************************\n\n\n"; 441 | cout<<"\t\t\t\t\t\t\t1. ADMIN SECTION \n"; 442 | cout<<"\t\t\t\t\t\t\t2. CUSTOMER SECTION \n"; 443 | cout<<"\t\t\t\t\t\t\t3. Exit \n\n"; 444 | cout<<"\t\t\t\t\t\t\tEnter Your Choice : "; 445 | } 446 | 447 | //This function is the Menu of canteen items 448 | void CanteenMenu(){ 449 | Canteen c; 450 | heada = createadmin(heada,1,"Hot and Sour Soup",100); 451 | heada = createadmin(heada,2,"Manchow Soup",200); 452 | heada = createadmin(heada,3,"Manchurian Noodles",150); 453 | heada = createadmin(heada,4,"Fried Rice",180); 454 | heada = createadmin(heada,5,"Hakka Noodles",80); 455 | 456 | while(1){ 457 | c.mainnenu(); 458 | int choice; 459 | cin>>choice; 460 | 461 | switch (choice){ 462 | case 1: 463 | system("cls"); 464 | c.admin(); 465 | break; 466 | case 2: 467 | system("cls"); 468 | c.customer(); 469 | break; 470 | case 3: 471 | system("cls"); 472 | cout<<"\n\n\t\t\t\t\t\t\t **********Thank you!!**********\n"; 473 | exit(1); 474 | exit(1); 475 | 476 | default: 477 | cout<<"\n\t\t\t\t\t\t\t Wrong Input !! PLease choose valid option\n "; 478 | break; 479 | } 480 | } 481 | } 482 | }; 483 | //End of Canteen Class 484 | -------------------------------------------------------------------------------- /DSA PROJECT/Hostel Management System/Contact_book.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | //This file is of Contact Book class which haveing circular Doubly Linked List, 7 | //this list have just two data one is the name of contact and other is number 8 | //This file contacts the File Handling with circular Doubly Linked List & bubble Sort with try throw & catch Functions 9 | 10 | //Concepts of Circular Doubly Linked List 11 | //Start Structure of Circular Doubly Linked List 12 | struct Node{ 13 | string name; 14 | long long int phone_number; 15 | Node *next; 16 | Node *prev; 17 | }; 18 | 19 | //Start of Contact Book List 20 | class ContactBook{ 21 | Node *head; 22 | string name; 23 | long long int number; 24 | public: 25 | //constructor of ContactBook class 26 | ContactBook(){ 27 | head=NULL; 28 | name=""; 29 | number=0; 30 | } 31 | // create function of duobly linked list for store the number of name 32 | void CreateNode(){ 33 | if(head==NULL){ 34 | Node *newer= new Node; 35 | 36 | cout<<" Name of Contact : "; 37 | cin>>name; 38 | newer->name=name; 39 | 40 | cout<<" Phone Number : "; 41 | cin>>number; 42 | newer->phone_number=number; 43 | 44 | newer->next=NULL; 45 | newer->prev==NULL; 46 | head=newer; 47 | 48 | cout<<" Contact Added"<>name; 55 | newer->name=name; 56 | 57 | cout<<" Phone Number : "; 58 | cin>>number; 59 | newer->phone_number=number; 60 | 61 | newer->next=NULL; 62 | 63 | Node *temp=head; 64 | while(temp->next!=NULL){ 65 | temp=temp->next; 66 | } 67 | temp->next=newer; 68 | newer->prev=temp; 69 | cout<<" Contact Added"<name; 87 | cout<<" "<phone_number<next; 89 | } 90 | cout<<" Total contacts : "<>command; 104 | 105 | if(command==1 && temp!=NULL){ 106 | cout<<" Enter the Name to Search : "; 107 | cin>>name; 108 | while(temp!=NULL){ 109 | if(temp->name==name){ 110 | cout<<"***********"<name<phone_number<next; 118 | } 119 | if(check==false){ 120 | cout<<" Name Not Found"<>number; 126 | 127 | while(temp!=NULL){ 128 | if(temp->phone_number==number){ 129 | cout<<"***********"<name<phone_number<next; 137 | } 138 | if(check==false){ 139 | cout<<" Number Not Found"<next; 156 | delete temp2; 157 | } 158 | head=NULL; 159 | cout<<" Successfully Deleted All Contacts"<>command; 174 | 175 | if(command==1){ 176 | bool Dcheck=false; 177 | cout<<" Enter the Name to Delete : "; 178 | cin>>name; 179 | while(temp!=NULL){ 180 | if(temp->name==name){ 181 | cout<<"***********"<name<phone_number<next; 189 | } 190 | if(Dcheck==true){ 191 | int command; 192 | cout<<" Press 1 to Delete the Contact : "; 193 | cin>>command; 194 | if(command==1 & temp==head){ 195 | Node *temp1; 196 | temp1=temp; 197 | temp=temp->next; 198 | delete temp1; 199 | 200 | temp->prev=NULL; 201 | head=temp; 202 | cout<<" Contact Deleted Success Fully"<next==NULL){ 205 | temp->prev->next=NULL; 206 | delete temp; 207 | cout<<" Contact Deleted Success Fully"<prev->next=temp1->next; 213 | temp->next->prev=temp1->prev; 214 | delete temp1; 215 | cout<<" Contact Deleted Success Fully"<>number; 229 | while(temp!=NULL){ 230 | if(temp->phone_number==number){ 231 | cout<<"***********"<name<phone_number<next; 239 | } 240 | 241 | if(Dcheck==true){ 242 | int command; 243 | cout<<" Press 1 to Delete the Contact : "; 244 | cin>>command; 245 | if(command==1 & temp==head){ 246 | Node *temp1; 247 | temp1=temp; 248 | temp=temp->next; 249 | delete temp1; 250 | 251 | temp->prev=NULL; 252 | head=temp; 253 | cout<<" Contact Deleted Success Fully"<next==NULL){ 256 | temp->prev->next=NULL; 257 | delete temp; 258 | cout<<" Contact Deleted Success Fully"<prev->next=temp1->next; 265 | temp->next->prev=temp1->prev; 266 | delete temp1; 267 | cout<<" Contact Deleted Success Fully"<next!=NULL;i=i->next) 294 | { 295 | for(j=i->next;j!=NULL;j=j->next) 296 | { 297 | if(i->name>j->name) 298 | { 299 | n=i->name; 300 | i->name=j->name; 301 | j->name=n; 302 | 303 | n2=i->phone_number; 304 | i->phone_number=j->phone_number; 305 | j->phone_number=n2; 306 | } 307 | } 308 | } 309 | } 310 | } 311 | 312 | //This function that can edit (edited name or number or both) the data of list cntact book 313 | int EditContacts(){ 314 | Node *temp=head; 315 | cout<<"***********"<>Ecommand; 321 | 322 | if(Ecommand==1){ 323 | bool Echeck=false; 324 | cout<<" Enter the Name to Edit : "; 325 | cin>>name; 326 | while(temp!=NULL){ 327 | if(temp->name==name){ 328 | cout<<"***********"<name<phone_number<next; 336 | } 337 | if(Echeck==true){ 338 | int command; 339 | cout<<" Press 1 to Edit the Contact : "; 340 | cin>>command; 341 | if(command==1){ 342 | cout<<" Enter New Name : "; 343 | cin>>name; 344 | cout<<" Enter New Number : "; 345 | cin>>number; 346 | 347 | temp->name=name; 348 | temp->phone_number=number; 349 | 350 | cout<<" Contact Edited Success Fully"<>number; 364 | while(temp!=NULL){ 365 | if(temp->phone_number==number){ 366 | cout<<"***********"<name<phone_number<next; 374 | } 375 | if(Echeck==true){ 376 | int command; 377 | cout<<" Press 1 to Edit the Contact : "; 378 | cin>>command; 379 | if(command==1){ 380 | cout<<" Enter New Name : "; 381 | cin>>name; 382 | cout<<" Enter New Number : "; 383 | cin>>number; 384 | 385 | temp->name=name; 386 | temp->phone_number=number; 387 | 388 | cout<<" Contact Edited Success Fully"<name<phone_number<next; 412 | } 413 | myfile.close(); 414 | Menu(); 415 | } 416 | else{ 417 | cout<<" Thanks file is empty."<name=name; 431 | 432 | newer->next=NULL; 433 | newer->prev==NULL; 434 | head=newer; 435 | } 436 | else{ 437 | Node *newer= new Node; 438 | 439 | newer->name=name; 440 | newer->next=NULL; 441 | 442 | Node *temp=head; 443 | while(temp->next!=NULL){ 444 | temp=temp->next; 445 | } 446 | temp->next=newer; 447 | newer->prev=temp; 448 | } 449 | } 450 | else{ 451 | Node *temp=head; 452 | if(temp->phone_number==0){ 453 | 454 | stringstream convert(name); 455 | convert>>number; 456 | temp->phone_number=number; 457 | } 458 | else{ 459 | Node *temp=head; 460 | while(temp->next!=NULL) 461 | { 462 | temp=temp->next; 463 | } 464 | 465 | stringstream convert(name); 466 | convert>>number; 467 | temp->phone_number=number; 468 | 469 | } 470 | 471 | } 472 | i++; 473 | } 474 | myfile.close(); 475 | } 476 | else 477 | { 478 | cout<<" File is Empty so Cannot open...Sorry"<>Scommand; 496 | try{ 497 | if(Scommand>=1&&Scommand<=6){ 498 | if(Scommand==1){ 499 | system("cls"); 500 | CreateNode(); 501 | OflineSave(); 502 | system("cls"); 503 | Menu(); 504 | } 505 | else if(Scommand==2){ 506 | system("cls"); 507 | EditContacts(); 508 | OflineSave(); 509 | system("cls"); 510 | Menu(); 511 | } 512 | else if(Scommand==3){ 513 | system("cls"); 514 | DeleteContactBySearch(); 515 | system("cls"); 516 | Menu(); 517 | } 518 | else if(Scommand==4){ 519 | system("cls"); 520 | Search(); 521 | system("cls"); 522 | Menu(); 523 | } 524 | else if(Scommand==5){ 525 | system("cls"); 526 | Display(); 527 | OflineSave(); 528 | system("cls"); 529 | Menu(); 530 | } 531 | else if(Scommand==6){ 532 | system("cls"); 533 | DeleteAllContacts(); 534 | OflineSave(); 535 | system("cls"); 536 | Menu(); 537 | } 538 | } 539 | else{ 540 | throw(Scommand); 541 | } 542 | } 543 | catch(int Scommand){ 544 | cout<<" You Enter wrong Command... Run the Code Again"<>n; 556 | system("cls"); 557 | cout<<"***********"< 2 | using namespace std; 3 | 4 | //This file is of Employees class which haveing doubly Linked List 5 | 6 | //Concepts of doubly Linked List 7 | 8 | //Start Structure of doubly Linked List 9 | struct node{ 10 | int id; 11 | char name[50]; 12 | char qua[30]; 13 | char addrs[50]; 14 | char city[30]; 15 | char jobtitle[30]; 16 | int salary; 17 | char date[30]; 18 | node *prev, *next; 19 | }; 20 | //End Structure of Singly Linked List 21 | 22 | //Start of Employ Class 23 | class employ{ 24 | public: 25 | 26 | node *head; 27 | char ch; 28 | //constructor of employ class 29 | employ(){ 30 | head = NULL; 31 | } 32 | //Function that show all the functionality of this class 33 | void menu(){ 34 | cout << "\n\t\t\t welcome to MAJU HOSTEL Employee Record system" << endl; 35 | cout << "\n\t\t\t\t 1-> Add a record" << endl; 36 | cout << "\n\t\t\t\t 2-> Search a record" << endl; 37 | cout << "\n\t\t\t\t 3-> Update a record" << endl; 38 | cout << "\n\t\t\t\t 4-> delete a record" << endl; 39 | cout << "\n\t\t\t\t 5-> Display a record" << endl; 40 | cout << "\n\t\t\t\t 0-> Exit " << endl; 41 | return; 42 | } 43 | 44 | //Concept of Insert in biggening of list 45 | //Function to store data in starting 46 | void add_first(){ 47 | cout<<"\n\t\t Please Enter Employee Details:"<> newer->id; 51 | fflush(stdin); 52 | cout << "\n\t\t Enter the full name of employee : "; 53 | cin.getline(newer->name, 50); 54 | fflush(stdin); 55 | cout << "\n\t\t Enter the qualification of employee : "; 56 | cin.getline(newer->qua, 30); 57 | fflush(stdin); 58 | cout << "\n\t\t Enter the address : "; 59 | cin.getline(newer->addrs, 50); 60 | fflush(stdin); 61 | cout << "\n\t\t Enter the city : "; 62 | cin.getline(newer->city, 30); 63 | fflush(stdin); 64 | cout << "\n\t\t Enter the job title : "; 65 | cin.getline(newer->jobtitle, 30); 66 | fflush(stdin); 67 | cout << "\n\t\t Enter the salary : "; 68 | cin >> newer->salary; 69 | fflush(stdin); 70 | cout << "\n\t\t Enter the start date : "; 71 | cin.getline(newer->date, 30); 72 | fflush(stdin); 73 | newer->next = head; 74 | newer->prev = NULL; 75 | if (head != NULL){ 76 | head->prev = newer; 77 | } 78 | head = newer; 79 | cout << "\n\t \t Record inserted successfully:" << endl; 80 | } 81 | 82 | //Concept of Insert in end of list 83 | //Function to store data in ending 84 | void add_last(){ 85 | if (head == NULL){ 86 | cout << "\n \t\t Link is empty :" << endl; 87 | cout << "\n \t \t Add a new record \n\t Press Y or N :"; 88 | cin >> ch; 89 | if (ch == 'Y' || ch == 'y'){ 90 | add_first(); 91 | return; 92 | } 93 | else{ 94 | exit(1); 95 | } 96 | } 97 | else{ 98 | node *temp = head; 99 | while (temp->next != NULL){ 100 | temp = temp->next; 101 | } 102 | node *newer = new node; 103 | cout << "\n\t\t Enter the employee id : "; 104 | cin >> newer->id; 105 | fflush(stdin); 106 | 107 | cout << "\n\t\t Enter the full name of employee : "; 108 | cin.getline(newer->name, 50); 109 | fflush(stdin); 110 | 111 | cout << "\n\t\t Enter the qualification of employee : "; 112 | cin.getline(newer->qua, 50); 113 | fflush(stdin); 114 | cout << "\n\t\t Enter the address : "; 115 | cin.getline(newer->addrs, 50); 116 | fflush(stdin); 117 | cout << "\n\t\t Enter the city : "; 118 | cin.getline(newer->city, 50); 119 | fflush(stdin); 120 | cout << "\n\t\t Enter the job title : "; 121 | cin.getline(newer->jobtitle, 50); 122 | fflush(stdin); 123 | cout << "\n\t\t Enter the salary : "; 124 | cin >> newer->salary; 125 | fflush(stdin); 126 | cout << "\n\t\t Enter the start date : "; 127 | cin.getline(newer->date, 30); 128 | fflush(stdin); 129 | newer->next = NULL; 130 | temp->next = newer; 131 | newer->prev = temp; 132 | } 133 | } 134 | 135 | //Concept of Insert in after of list 136 | //Function to store data after particular node 137 | void add_after(){ 138 | if (head == NULL){ 139 | cout << "\n\t\t List is empty : " << endl; 140 | cout << "\n\t\t Add a new record \n\t Press y or n : "; 141 | cin >> ch; 142 | if (ch == 'Y' || ch == 'y'){ 143 | add_first(); 144 | return; 145 | } 146 | else{ 147 | exit(1); 148 | } 149 | } 150 | else{ 151 | int val; 152 | cout << "\n\t\t Enter the id after which you want to add a new record : "; 153 | cin >> val; 154 | bool flag = false; 155 | node *temp = head; 156 | node*p; 157 | while (temp != NULL){ 158 | if (temp->id == val){ 159 | node*newer = new node; 160 | fflush(stdin); 161 | cout << "\n\t\t Enter the employee id : "; 162 | cin >> newer->id; 163 | fflush(stdin); 164 | 165 | cout << "\n\t\t Enter the full name of employee : "; 166 | cin.getline(newer->name, 50); 167 | fflush(stdin); 168 | 169 | cout << "\n\t\t enter the qualification of employee : "; 170 | cin.getline(newer->qua, 50); 171 | fflush(stdin); 172 | cout << "\n\t\t Enter the address : "; 173 | cin.getline(newer->addrs, 50); 174 | fflush(stdin); 175 | cout << "\n\t\t Enter the city : "; 176 | cin.getline(newer->city, 50); 177 | fflush(stdin); 178 | cout << "\n\t\t Enter the job title : "; 179 | cin.getline(newer->jobtitle, 50); 180 | fflush(stdin); 181 | cout << "\n\t\t Enter the salary : "; 182 | cin >> newer->salary; 183 | fflush(stdin); 184 | cout << "\n\t\t Enter the start date : "; 185 | cin.getline(newer->date, 30); 186 | fflush(stdin); 187 | if (temp->next != NULL){ 188 | newer->next = temp->next; 189 | newer->prev = temp; 190 | p = temp->next; 191 | p->prev = newer; 192 | temp->next = newer; 193 | } 194 | else{ 195 | newer->next = temp->next; 196 | newer->prev = temp; 197 | temp->next = newer; 198 | } 199 | flag = true; 200 | } 201 | temp = temp->next; 202 | } 203 | if (flag == false){ 204 | cout << "\n\t\t ID not found" << endl; 205 | } 206 | } 207 | } 208 | 209 | void add_before(){ 210 | if (head == NULL){ 211 | cout << "\n\t\t List is empty : " << endl; 212 | cout << "\n\t\t Add a new record\n\t Press Y or N : "; 213 | cin >> ch; 214 | if (ch == 'Y' || ch == 'y'){ 215 | add_first(); 216 | return; 217 | } 218 | else{ 219 | exit(1); 220 | } 221 | } 222 | else{ 223 | int val; 224 | cout << "\n\t\t Enter the id beofre which you want to add a new record : " << endl; 225 | cin >> val; 226 | bool flag = false; 227 | node *temp = head; 228 | if (temp->id = val){ 229 | add_first(); 230 | return; 231 | } 232 | else{ 233 | while (temp != NULL){ 234 | if (temp->id == val){ 235 | node*newer = new node; 236 | fflush(stdin); 237 | cout << "\n\t\t Enter the employee id : "; 238 | cin >> newer->id; 239 | fflush(stdin); 240 | 241 | cout << "\n\t\t Enter the full name of employee : "; 242 | cin.getline(newer->name, 50); 243 | fflush(stdin); 244 | 245 | cout << "\n\t\t Enter the qualification of employee : "; 246 | cin.getline(newer->qua, 50); 247 | fflush(stdin); 248 | cout << "\n\t\t Enter the address : "; 249 | cin.getline(newer->addrs, 50); 250 | fflush(stdin); 251 | cout << "\n\t\t Enter the city : "; 252 | cin.getline(newer->city, 50); 253 | fflush(stdin); 254 | cout << "\n\t\t Enter the job title : "; 255 | cin.getline(newer->jobtitle, 50); 256 | fflush(stdin); 257 | cout << "\n\t\t Enter the salary : "; 258 | cin >> newer->salary; 259 | fflush(stdin); 260 | cout << "\n\t\t Enter the start date : "; 261 | cin.getline(newer->date, 30); 262 | fflush(stdin); 263 | newer->next = temp; 264 | newer->prev = temp; 265 | node*p; 266 | p = temp->prev; 267 | p->next = newer; 268 | temp->prev = newer; 269 | flag = true; 270 | } 271 | temp = temp->next; 272 | } 273 | if (flag == false) 274 | { 275 | cout << "\n\t\t Record is not found" << endl; 276 | } 277 | } 278 | } 279 | } 280 | 281 | //Concept of deletion in list 282 | //Function to delete data from list 283 | void del(){ 284 | if (head == NULL){ 285 | cout << "\n\t\t List is empty" << endl; 286 | cout << "\n\t\t add a new record\n\t Press Y to proceed or N to exit : "; 287 | cin >> ch; 288 | if (ch == 'Y' || ch == 'y'){ 289 | add_first(); 290 | return; 291 | } 292 | else{ 293 | exit(1); 294 | } 295 | } 296 | else{ 297 | int val; 298 | cout << "\n\t\t Enter the employee id which do you want to delete a record : "; 299 | cin >> val; 300 | node*temp = head; 301 | bool flag = false; 302 | if (temp->id == val){ 303 | head = temp->next; 304 | head->prev = NULL; 305 | flag = true; 306 | delete temp; 307 | if (flag == true){ 308 | cout << "Record has been deleted successfully" << endl; 309 | } 310 | } 311 | else{ 312 | while (temp != NULL){ 313 | if (temp->id == val){ 314 | node *p, *q; 315 | if (temp->next == NULL){ 316 | p = temp->prev; 317 | p->next = NULL; 318 | flag = true; 319 | delete temp; 320 | } 321 | 322 | else{ 323 | p = temp->prev; 324 | q = temp->next; 325 | p->next = q; 326 | q->prev = p; 327 | flag = true; 328 | delete temp; 329 | } 330 | } 331 | temp = temp->next; 332 | } 333 | if (flag == false){ 334 | cout << "\n\t Value is not found" << endl; 335 | } 336 | } 337 | } 338 | } 339 | 340 | //Function that dispaly the data of list 341 | void show(){ 342 | if (head == NULL){ 343 | cout << "\n\t\t List is empty" << endl; 344 | cout << "\n\t\t Add a new record \n\t Press Y to proceed or N to exit : "; 345 | cin >> ch; 346 | if (ch == 'Y' || ch == 'y'){ 347 | add_first(); 348 | return; 349 | } 350 | else{ 351 | exit(1); 352 | } 353 | } 354 | else{ 355 | node*temp = head; 356 | while (temp != NULL){ 357 | cout << "\n\t\t Information of employee " << endl; 358 | cout << "\n\t\t ID : " << "\t\t\t" << temp->id << endl; 359 | cout << "\n\t\t Name : " << "\t\t\t" << temp->name << endl; 360 | cout << "\n\t\t Qualification : " << "\t\t" << temp->qua << endl; 361 | cout << "\n\t\t Address : " << "\t\t" << temp->addrs << endl; 362 | cout << "\n\t\t City : " << "\t\t\t" << temp->city << endl; 363 | cout << "\n\t\t Job title : ""\t\t" << temp->jobtitle << endl; 364 | cout << "\n\t\t Salary : " << "\t\t" << temp->salary << endl; 365 | cout << "\n\t\t Starting date : " << "\t\t" << temp->date << endl; 366 | cout << "_______________________________________________________" << endl; 367 | temp = temp->next; 368 | } 369 | } 370 | } 371 | //Concept of searching in doubly linked list 372 | //Function to store data in starting 373 | void search(){ 374 | if (head == NULL){ 375 | cout << "\n\t\t List is empty" << endl; 376 | cout << "\n\t\t Add a new record \n\t Press Y to proceed or N to exit : "; 377 | cin >> ch; 378 | if (ch == 'Y' || ch == 'y'){ 379 | add_first(); 380 | return; 381 | } 382 | else{ 383 | exit(1); 384 | } 385 | } 386 | else{ 387 | int val; 388 | cout << "\n\t\t Enter employee ID which you want to search : "; 389 | cin >> val; 390 | node *temp = head; 391 | bool flag = false; 392 | while (temp != NULL){ 393 | if (temp->id == val){ 394 | cout << "\n\t\t Information of employee" << endl; 395 | cout << "\n\t\t ID : " << "\t\t\t" << temp->id << endl; 396 | cout << "\n\t\t Name : " << "\t\t\t" << temp->name << endl; 397 | cout << "\n\t\t Qualification : " << "\t\t" << temp->qua << endl; 398 | cout << "\n\t\t Address : " << "\t\t" << temp->addrs << endl; 399 | cout << "\n\t\t City : " << "\t\t\t" << temp->city << endl; 400 | cout << "\n\t\t Job title : ""\t\t" << temp->jobtitle << endl; 401 | cout << "\n\t\t Salary : " << "\t\t" << temp->salary << endl; 402 | cout << "\n\t\t Starting date : " << "\t\t" << temp->date << endl; 403 | cout << "_______________________________________________________" << endl; 404 | return; 405 | } 406 | temp = temp->next; 407 | } 408 | } 409 | } 410 | 411 | //Concept of edit data of doubly linked list 412 | //Function to update data of doubly linked list 413 | void update(){ 414 | if (head == NULL){ 415 | cout << "\n\t\t List is empty" << endl; 416 | cout << "\n\t\t Add a new record \n\t Press Y to proceed or N to exit : " << endl; 417 | cin >> ch; 418 | if (ch == 'Y' || ch == 'y'){ 419 | add_first(); 420 | return; 421 | } 422 | else{ 423 | exit(1); 424 | } 425 | } 426 | else{ 427 | int val; 428 | cout << "\n\t\t Enter the emplyee ID whose record you want to update "; 429 | cin >> val; 430 | node*temp = head; 431 | node *newer = new node; 432 | while (temp != NULL){ 433 | if (temp->id == val){ 434 | fflush(stdin); 435 | cout << "\n\t\t Enter the employee id : "; 436 | cin >> newer->id; 437 | fflush(stdin); 438 | 439 | cout << "\n\t\t Enter the full name of employee : "; 440 | cin.getline(newer->name, 50); 441 | fflush(stdin); 442 | 443 | cout << "\n\t\t enter the qualification of employee : "; 444 | cin.getline(newer->qua, 50); 445 | fflush(stdin); 446 | cout << "\n\t\t Enter the address : "; 447 | cin.getline(newer->addrs, 50); 448 | fflush(stdin); 449 | cout << "\n\t\t Enter the city : "; 450 | cin.getline(newer->city, 50); 451 | fflush(stdin); 452 | cout << "\n\t\t Enter the job title : "; 453 | cin.getline(newer->jobtitle, 50); 454 | fflush(stdin); 455 | cout << "\n\t\t Enter the salary : "; 456 | cin >> newer->salary; 457 | fflush(stdin); 458 | cout << "\n\t\t Enter the start date : "; 459 | cin.getline(newer->date, 30); 460 | fflush(stdin); 461 | } 462 | temp = temp->next; 463 | } 464 | cout << "Record has been updated successfully" << endl; 465 | } 466 | } 467 | 468 | //The Main Menu Function of employee class that can show all the functionality of this function 469 | void Employmain(){ 470 | int n; 471 | char ch; 472 | employ en; 473 | Label2: 474 | system("cls"); 475 | en.menu(); 476 | cout << "\n\t\t\t Enter your choice : "; 477 | cin >> n; 478 | if (n == 1){ 479 | system("cls"); 480 | Label1: 481 | cout << "_______________________________________" << endl; 482 | cout << "\n\t\t Where you want to Add Record " << endl; 483 | cout << "\t\t\t" << endl; 484 | cout << "\n\t\t 1-> Insert at very first place " << endl; 485 | cout << "\n\t\t 2-> Insert at very last place " << endl; 486 | cout << "\n\t\t 3-> Insert after recently added record(pointer pointing at this) " << endl; 487 | cout << "\n\t\t 4-> Insert before record " << endl; 488 | cout << "\n\t\t Enter Choice : " << endl; 489 | cin >> n; 490 | 491 | if (n == 1){ 492 | system("cls"); 493 | en.add_first(); 494 | cout << "\n\t\t do you want to go to main menu (y/n) : "; 495 | cin >> ch; 496 | fflush(stdin); 497 | if (ch == 'Y' || ch == 'y'){ 498 | goto Label2; 499 | } 500 | else{ 501 | exit(1); 502 | } 503 | } 504 | 505 | else if (n == 2){ 506 | system("cls"); 507 | en.add_last(); 508 | cout << "\n\t\t do you want to go to main menu : "; 509 | cin >> ch; 510 | if (ch == 'Y' || ch == 'y'){ 511 | goto Label2; 512 | } 513 | else{ 514 | exit(1); 515 | } 516 | } 517 | 518 | else if (n == 3){ 519 | system("cls"); 520 | en.add_after(); 521 | cout << "\n\t\t Do you want to go to main menu : "; 522 | cin >> ch; 523 | if (ch == 'Y' || ch == 'y'){ 524 | goto Label2; 525 | } 526 | else{ 527 | exit(1); 528 | } 529 | } 530 | 531 | else if (n == 4){ 532 | system("cls"); 533 | en.add_before(); 534 | cout << "\n\t\t Do you want to go to main menu (Y/N) : "; 535 | cin >> ch; 536 | if (ch == 'Y' || ch == 'y'){ 537 | goto Label2; 538 | } 539 | else{ 540 | exit(1); 541 | } 542 | } 543 | else{ 544 | cout << "\n\t\t Choose Correct Answer : " << endl; 545 | goto Label1; 546 | } 547 | } 548 | 549 | else if (n == 2){ 550 | system("cls"); 551 | en.search(); 552 | cout << "\n\t\t Do you want to go to main menu (Y/N) : " ; 553 | cin >> ch; 554 | if (ch == 'Y' || ch == 'y'){ 555 | goto Label2; 556 | } 557 | else{ 558 | exit(1); 559 | } 560 | } 561 | 562 | else if (n == 3){ 563 | system("cls"); 564 | en.update(); 565 | cout << "\n\t\t Do you want to go to main menu (Y/N) : "; 566 | cin >> ch; 567 | if (ch == 'Y' || ch == 'y'){ 568 | goto Label2; 569 | } 570 | else{ 571 | exit(1); 572 | } 573 | } 574 | 575 | else if (n == 4){ 576 | system("cls"); 577 | en.del(); 578 | cout << "\n\t\t Do you want to go to main menu (Y/N) : " ; 579 | cin >> ch; 580 | if (ch == 'Y' || ch == 'y'){ 581 | goto Label2; 582 | } 583 | else{ 584 | exit(0); 585 | } 586 | } 587 | 588 | else if (n == 5){ 589 | system("cls"); 590 | en.show(); 591 | cout << "\n\t\t Do you want to go to main menu (Y/N) : " ; 592 | cin >> ch; 593 | if (ch == 'Y' || ch == 'y'){ 594 | goto Label2; 595 | } 596 | else{ 597 | exit(1); 598 | } 599 | } 600 | 601 | else if (n == 6){ 602 | system("cls"); 603 | exit(1); 604 | } 605 | 606 | else{ 607 | cout << "\n\t\t Choose correct answer" << endl; 608 | goto Label2; 609 | } 610 | system("pause"); 611 | } 612 | }; 613 | //End of Employ Class 614 | --------------------------------------------------------------------------------