├── 20211121_145218.jpeg.jpg ├── Basic_programs └── C++ │ ├── Factorial of a Given Number using c++ │ ├── Merge_Sort.cpp │ └── Odd_Divisor(codeforces).cpp ├── CONTRIBUTING.md ├── DSA Problems - Solutions ├── Graphs │ └── Dijkstra'sAlgorithm.cpp ├── Linked Lists │ ├── Delete middle of linked list.cpp │ ├── linked_list_insertion.py │ └── mrege_two_link_list.cpp └── Strings │ └── is_palindrome.py ├── LICENSE ├── LeetCodes - Solutions └── C++ │ ├── Leetcode 3Sum Problem - 15.py │ ├── best_time_to_buy_and_sell.cpp │ └── find-median-from-data-stream.cpp ├── Projects ├── Abc │ ├── .classpath │ ├── .project │ ├── .settings │ │ └── org.eclipse.jdt.core.prefs │ ├── bin │ │ └── com │ │ │ └── apps │ │ │ ├── beans │ │ │ └── Student.class │ │ │ ├── config │ │ │ └── applicationContext.xml │ │ │ └── test │ │ │ └── Client.class │ └── src │ │ └── com │ │ └── apps │ │ ├── beans │ │ └── Student.java │ │ ├── config │ │ └── applicationContext.xml │ │ └── test │ │ └── Client.java ├── DynamicForm │ ├── .classpath │ ├── .project │ ├── .settings │ │ ├── .jsdtscope │ │ ├── org.eclipse.jdt.core.prefs │ │ ├── org.eclipse.wst.common.component │ │ ├── org.eclipse.wst.common.project.facet.core.xml │ │ ├── org.eclipse.wst.jsdt.ui.superType.container │ │ └── org.eclipse.wst.jsdt.ui.superType.name │ ├── WebContent │ │ ├── META-INF │ │ │ └── MANIFEST.MF │ │ └── WEB-INF │ │ │ └── web.xml │ ├── build │ │ └── classes │ │ │ └── com │ │ │ └── spiosys │ │ │ └── servlet │ │ │ ├── EditFormServlet.class │ │ │ └── UpdateServlet.class │ └── src │ │ └── com │ │ └── spiosys │ │ └── servlet │ │ ├── EditFormServlet.java │ │ └── UpdateServlet.java ├── Hotel Management System │ ├── README.md │ ├── add_guest.cpp │ ├── calculate_rent.cpp │ ├── customer.cpp │ ├── insertion_check.cpp │ ├── main.cpp │ ├── main.exe │ ├── query_exec.cpp │ ├── refresh_db.cpp │ ├── room.cpp │ ├── room_allotment.cpp │ └── update_checkout.cpp ├── Lbraray Management System │ └── LMS BY Krishnika │ │ ├── README.md │ │ ├── mainprogram.cpp │ │ └── output.exe ├── Rock_Paper_Scissors.cpp ├── Score Keeping Game │ ├── ScoreKeeping_Game │ ├── app.js │ └── index.html ├── Student Grading System │ ├── README.md │ ├── Student Grading System.py │ └── calculator.html ├── ege catcher │ └── egecatcher.py └── helmet.py ├── README.md ├── Remove duplicates from a sorted linked list.cpp ├── Subway Ride.java └── Subway Ride.java ├── armstrong.py ├── logo.png └── quickSort.java /20211121_145218.jpeg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RajkumarSony/HacktoberFest2022/2268dfd80de7213007f1241365eb25e7810710f4/20211121_145218.jpeg.jpg -------------------------------------------------------------------------------- /Basic_programs/C++/Factorial of a Given Number using c++: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int n; 6 | long factorial = 1.0; 7 | 8 | cout << "Enter a positive integer: "; 9 | cin >> n; 10 | 11 | if (n < 0) 12 | cout << "Error! Factorial of a negative number doesn't exist."; 13 | else { 14 | for(int i = 1; i <= n; ++i) { 15 | factorial *= i; 16 | } 17 | cout << "Factorial of " << n << " = " << factorial; 18 | } 19 | 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /Basic_programs/C++/Merge_Sort.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | 5 | void merge(int array[], int const left, int const mid, 6 | int const right) 7 | { 8 | auto const subArrayOne = mid - left + 1; 9 | auto const subArrayTwo = right - mid; 10 | 11 | 12 | auto *leftArray = new int[subArrayOne], 13 | *rightArray = new int[subArrayTwo]; 14 | 15 | 16 | for (auto i = 0; i < subArrayOne; i++) 17 | leftArray[i] = array[left + i]; 18 | for (auto j = 0; j < subArrayTwo; j++) 19 | rightArray[j] = array[mid + 1 + j]; 20 | 21 | auto indexOfSubArrayOne 22 | = 0, 23 | indexOfSubArrayTwo 24 | = 0; 25 | int indexOfMergedArray 26 | = left; 27 | 28 | 29 | while (indexOfSubArrayOne < subArrayOne 30 | && indexOfSubArrayTwo < subArrayTwo) { 31 | if (leftArray[indexOfSubArrayOne] 32 | <= rightArray[indexOfSubArrayTwo]) { 33 | array[indexOfMergedArray] 34 | = leftArray[indexOfSubArrayOne]; 35 | indexOfSubArrayOne++; 36 | } 37 | else { 38 | array[indexOfMergedArray] 39 | = rightArray[indexOfSubArrayTwo]; 40 | indexOfSubArrayTwo++; 41 | } 42 | indexOfMergedArray++; 43 | } 44 | 45 | while (indexOfSubArrayOne < subArrayOne) { 46 | array[indexOfMergedArray] 47 | = leftArray[indexOfSubArrayOne]; 48 | indexOfSubArrayOne++; 49 | indexOfMergedArray++; 50 | } 51 | 52 | while (indexOfSubArrayTwo < subArrayTwo) { 53 | array[indexOfMergedArray] 54 | = rightArray[indexOfSubArrayTwo]; 55 | indexOfSubArrayTwo++; 56 | indexOfMergedArray++; 57 | } 58 | delete[] leftArray; 59 | delete[] rightArray; 60 | } 61 | 62 | 63 | void mergeSort(int array[], int const begin, int const end) 64 | { 65 | if (begin >= end) 66 | return; 67 | 68 | auto mid = begin + (end - begin) / 2; 69 | mergeSort(array, begin, mid); 70 | mergeSort(array, mid + 1, end); 71 | merge(array, begin, mid, end); 72 | } 73 | 74 | 75 | void printArray(int A[], int size) 76 | { 77 | for (auto i = 0; i < size; i++) 78 | cout << A[i] << " "; 79 | } 80 | 81 | 82 | int main() 83 | { 84 | int arr[] = { 12, 11, 13, 5, 6, 7 }; 85 | auto arr_size = sizeof(arr) / sizeof(arr[0]); 86 | 87 | cout << "Given array is \n"; 88 | printArray(arr, arr_size); 89 | 90 | mergeSort(arr, 0, arr_size - 1); 91 | 92 | cout << "\nSorted array is \n"; 93 | printArray(arr, arr_size); 94 | return 0; 95 | } 96 | 97 | 98 | -------------------------------------------------------------------------------- /Basic_programs/C++/Odd_Divisor(codeforces).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main(){ 4 | int t; 5 | cin>>t; 6 | while(t--){ 7 | long long n; 8 | cin>>n; 9 | if(n&(n-1)){ 10 | cout<<"YES"< 5 | using namespace std; 6 | 7 | // Number of vertices in the graph 8 | #define V 9 9 | 10 | // A utility function to find the vertex with minimum 11 | // distance value, from the set of vertices not yet included 12 | // in shortest path tree 13 | int minDistance(int dist[], bool sptSet[]){ 14 | 15 | // Initialize min value 16 | int min = INT_MAX, min_index; 17 | 18 | for (int v = 0; v < V; v++) 19 | if (sptSet[v] == false && dist[v] <= min) 20 | min = dist[v], min_index = v; 21 | 22 | return min_index; 23 | } 24 | 25 | // A utility function to print the constructed distance 26 | // array 27 | void printSolution(int dist[]){ 28 | 29 | cout << "Vertex \t Distance from Source" << endl; 30 | for (int i = 0; i < V; i++) 31 | cout << i << " \t\t\t\t" << dist[i] << endl; 32 | } 33 | 34 | // Function that implements Dijkstra's single source 35 | // shortest path algorithm for a graph represented using 36 | // adjacency matrix representation 37 | void dijkstra(int graph[V][V], int src) 38 | { 39 | int dist[V]; // The output array. dist[i] will hold the 40 | // shortest 41 | // distance from src to i 42 | 43 | bool sptSet[V]; // sptSet[i] will be true if vertex i is 44 | // included in shortest 45 | // path tree or shortest distance from src to i is 46 | // finalized 47 | 48 | // Initialize all distances as INFINITE and stpSet[] as 49 | // false 50 | for (int i = 0; i < V; i++) 51 | dist[i] = INT_MAX, sptSet[i] = false; 52 | 53 | // Distance of source vertex from itself is always 0 54 | dist[src] = 0; 55 | 56 | // Find shortest path for all vertices 57 | for (int count = 0; count < V - 1; count++) { 58 | // Pick the minimum distance vertex from the set of 59 | // vertices not yet processed. u is always equal to 60 | // src in the first iteration. 61 | int u = minDistance(dist, sptSet); 62 | 63 | // Mark the picked vertex as processed 64 | sptSet[u] = true; 65 | 66 | // Update dist value of the adjacent vertices of the 67 | // picked vertex. 68 | for (int v = 0; v < V; v++) 69 | 70 | // Update dist[v] only if is not in sptSet, 71 | // there is an edge from u to v, and total 72 | // weight of path from src to v through u is 73 | // smaller than current value of dist[v] 74 | if (!sptSet[v] && graph[u][v] 75 | && dist[u] != INT_MAX 76 | && dist[u] + graph[u][v] < dist[v]) 77 | dist[v] = dist[u] + graph[u][v]; 78 | } 79 | 80 | // print the constructed distance array 81 | printSolution(dist); 82 | } 83 | 84 | // driver's code 85 | int main() 86 | { 87 | /* Let us create the example graph discussed above */ 88 | int graph[V][V] = { { 0, 4, 0, 0, 0, 0, 0, 8, 0 }, 89 | { 4, 0, 8, 0, 0, 0, 0, 11, 0 }, 90 | { 0, 8, 0, 7, 0, 4, 0, 0, 2 }, 91 | { 0, 0, 7, 0, 9, 14, 0, 0, 0 }, 92 | { 0, 0, 0, 9, 0, 10, 0, 0, 0 }, 93 | { 0, 0, 4, 14, 10, 0, 2, 0, 0 }, 94 | { 0, 0, 0, 0, 0, 2, 0, 1, 6 }, 95 | { 8, 11, 0, 0, 0, 0, 1, 0, 7 }, 96 | { 0, 0, 2, 0, 0, 0, 6, 7, 0 } }; 97 | 98 | // Function call 99 | dijkstra(graph, 0); 100 | 101 | return 0; 102 | } -------------------------------------------------------------------------------- /DSA Problems - Solutions/Linked Lists/Delete middle of linked list.cpp: -------------------------------------------------------------------------------- 1 | // C++ program to delete middle of a linked list 2 | #include 3 | using namespace std; 4 | 5 | /* Link list Node */ 6 | struct Node { 7 | int data; 8 | struct Node* next; 9 | }; 10 | // count of nodes 11 | int countOfNodes(struct Node* head) 12 | { 13 | int count = 0; 14 | while (head != NULL) { 15 | head = head->next; 16 | count++; 17 | } 18 | return count; 19 | } 20 | 21 | // Deletes middle node and returns 22 | // head of the modified list 23 | struct Node* deleteMid(struct Node* head) 24 | { 25 | // Base cases 26 | if (head == NULL) 27 | return NULL; 28 | if (head->next == NULL) { 29 | delete head; 30 | return NULL; 31 | } 32 | struct Node* copyHead = head; 33 | // Find the count of nodes 34 | int count = countOfNodes(head); 35 | // Find the middle node 36 | int mid = count / 2; 37 | // Delete the middle node 38 | while (mid-- > 1) 39 | head = head->next; 40 | // Delete the middle node 41 | head->next = head->next->next; 42 | return copyHead; 43 | } 44 | 45 | // A utility function to print 46 | // a given linked list 47 | void printList(struct Node* ptr) 48 | { 49 | while (ptr != NULL) { 50 | cout << ptr->data << "->"; 51 | ptr = ptr->next; 52 | } 53 | cout << "NULL\n"; 54 | } 55 | 56 | // Utility function to create a new node. 57 | Node* newNode(int data) 58 | { 59 | struct Node* temp = new Node; 60 | temp->data = data; 61 | temp->next = NULL; 62 | return temp; 63 | } 64 | 65 | /* Driver program to test above function*/ 66 | int main() 67 | { 68 | /* Start with the empty list */ 69 | struct Node* head = newNode(1); 70 | head->next = newNode(2); 71 | head->next->next = newNode(3); 72 | head->next->next->next = newNode(4); 73 | 74 | cout << "Given Linked List\n"; 75 | printList(head); 76 | head = deleteMid(head); 77 | cout << "Linked List after deletion of middle\n"; 78 | printList(head); 79 | return 0; 80 | } 81 | 82 | // This code is contributed by Aditya Kumar (adityakumar129) 83 | -------------------------------------------------------------------------------- /DSA Problems - Solutions/Linked Lists/linked_list_insertion.py: -------------------------------------------------------------------------------- 1 | # Creating a Linked List 2 | 3 | 4 | class Node: 5 | def __init__(self, data): 6 | self.data = data 7 | self.next = None 8 | 9 | 10 | class Linkedlist: 11 | def __init__(self): 12 | self.head = None 13 | 14 | # fn to print the List 15 | def print_linked_list(self): 16 | if self.head == None: 17 | print("Linked List is empty!") 18 | else: 19 | n = self.head 20 | while n != None: 21 | print(n.data, "-->", end=" ") 22 | n = n.next 23 | 24 | # fn to add a node at the beginning of list 25 | def insert_start(self, data): 26 | new_node = Node(data) 27 | new_node.next = self.head 28 | self.head = new_node 29 | 30 | # fn to add a node at the end of list 31 | def insert_end(self, data): 32 | new_node = Node(data) 33 | if self.head == None: 34 | self.head = new_node 35 | return 36 | else: 37 | n = self.head 38 | while n.next != None: 39 | n = n.next 40 | n.next = new_node 41 | 42 | # fn to add a node after a given position 43 | def insert_at(self, data, node): 44 | temp = self.head 45 | while temp is not None: 46 | if temp.data == node: 47 | break 48 | temp = temp.next 49 | if node is None: 50 | return "Item not found in Llist" 51 | else: 52 | new_node = Node(data) 53 | new_node.next = temp.next 54 | temp.next = new_node 55 | 56 | 57 | LL1 = Linkedlist() 58 | LL1.insert_end(5) 59 | LL1.insert_end(10) 60 | LL1.insert_end(20) 61 | print(LL1.print_linked_list()) 62 | 63 | LL1.insert_at(15, 10) 64 | print(LL1.print_linked_list()) 65 | -------------------------------------------------------------------------------- /DSA Problems - Solutions/Linked Lists/mrege_two_link_list.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | class Node 4 | { 5 | public: 6 | int data; 7 | Node *next; 8 | }; 9 | void insert(Node **, int); 10 | void Print(Node *); 11 | void merge(Node *, Node **); 12 | int main() 13 | { 14 | Node *first = NULL, *second = NULL; 15 | insert(&first, 5); 16 | insert(&first, 4); 17 | insert(&first, 3); 18 | insert(&first, 2); 19 | insert(&first, 1); 20 | cout<<"First Linked List:\n"; 21 | Print(first); 22 | insert(&second, 10); 23 | insert(&second, 9); 24 | insert(&second, 8); 25 | insert(&second, 7); 26 | insert(&second, 6); 27 | cout<<"\nSecond Linked List:\n"; 28 | Print(second); 29 | merge(first, &second); 30 | cout<<"\nMerged list is: "; 31 | Print(first); 32 | return 0; 33 | } 34 | void insert(Node ** head_ref, int new_data) 35 | { 36 | Node* new_node = new Node(); 37 | new_node->data = new_data; 38 | new_node->next = (*head_ref); 39 | (*head_ref) = new_node; 40 | } 41 | void Print(Node *head) 42 | { 43 | Node *temp = head; 44 | while (temp != NULL) 45 | { 46 | cout<data<<" "; 47 | temp = temp->next; 48 | } 49 | cout<next != NULL) 54 | { 55 | firstRef = firstRef->next; 56 | } 57 | firstRef->next = *second; 58 | } 59 | -------------------------------------------------------------------------------- /DSA Problems - Solutions/Strings/is_palindrome.py: -------------------------------------------------------------------------------- 1 | # fn to check whether string is palindrome 2 | # Time Complexity = O(n) and Space Complexity = O(1) 3 | 4 | 5 | def is_palindrome(string1): 6 | low = 0 7 | high = len(string1) - 1 8 | while low < high: 9 | if string1[low].lower() != string1[high].lower(): 10 | return False 11 | else: 12 | low += 1 13 | high -= 1 14 | return True 15 | 16 | 17 | # Driver's Code 18 | string1 = "Abcba" 19 | 20 | if is_palindrome(string1): 21 | print("String is palindrome") 22 | else: 23 | print("String is not palindrome") 24 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Rajkumar Sony 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /LeetCodes - Solutions/C++/Leetcode 3Sum Problem - 15.py: -------------------------------------------------------------------------------- 1 | def threeSum(self, nums: List[int]) -> List[List[int]]: 2 | 3 | res = set() 4 | 5 | #1. Split nums into three lists: negative numbers, positive numbers, and zeros 6 | n, p, z = [], [], [] 7 | for num in nums: 8 | if num > 0: 9 | p.append(num) 10 | elif num < 0: 11 | n.append(num) 12 | else: 13 | z.append(num) 14 | 15 | #2. Create a separate set for negatives and positives for O(1) look-up times 16 | N, P = set(n), set(p) 17 | 18 | #3. If there is at least 1 zero in the list, add all cases where -num exists in N and num exists in P 19 | # i.e. (-3, 0, 3) = 0 20 | if z: 21 | for num in P: 22 | if -1*num in N: 23 | res.add((-1*num, 0, num)) 24 | 25 | #3. If there are at least 3 zeros in the list then also include (0, 0, 0) = 0 26 | if len(z) >= 3: 27 | res.add((0,0,0)) 28 | 29 | #4. For all pairs of negative numbers (-3, -1), check to see if their complement (4) 30 | # exists in the positive number set 31 | for i in range(len(n)): 32 | for j in range(i+1,len(n)): 33 | target = -1*(n[i]+n[j]) 34 | if target in P: 35 | res.add(tuple(sorted([n[i],n[j],target]))) 36 | 37 | #5. For all pairs of positive numbers (1, 1), check to see if their complement (-2) 38 | # exists in the negative number set 39 | for i in range(len(p)): 40 | for j in range(i+1,len(p)): 41 | target = -1*(p[i]+p[j]) 42 | if target in N: 43 | res.add(tuple(sorted([p[i],p[j],target]))) 44 | 45 | return res 46 | -------------------------------------------------------------------------------- /LeetCodes - Solutions/C++/best_time_to_buy_and_sell.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | void answer(int n){ 5 | 6 | for(int i=1;i<=n;i++){ 7 | for(int j=1;j<=n;j++){ 8 | if(i<=j){ 9 | cout<<"*"; 10 | } 11 | else{ 12 | cout<<" "; 13 | } 14 | } 15 | for(int j=1;j<=n-i;j++){ 16 | cout<<"*"; 17 | } 18 | cout<<"\n"; 19 | } 20 | } 21 | 22 | int main(){ 23 | int n; 24 | cin>>n; 25 | answer(n); 26 | } -------------------------------------------------------------------------------- /LeetCodes - Solutions/C++/find-median-from-data-stream.cpp: -------------------------------------------------------------------------------- 1 | class MedianFinder { 2 | public: 3 | priority_queue maxh; 4 | priority_queue, greater> minh; 5 | 6 | MedianFinder() { 7 | 8 | } 9 | 10 | void addNum(int num) { 11 | maxh.push(num); 12 | minh.push(maxh.top()); 13 | maxh.pop(); 14 | if(maxh.size() < minh.size()){ 15 | maxh.push(minh.top()); 16 | minh.pop(); 17 | } 18 | } 19 | 20 | double findMedian() { 21 | if(maxh.size()==minh.size()){ 22 | double t = maxh.top()+minh.top(); 23 | return t/2.0; 24 | } 25 | 26 | return maxh.top(); 27 | } 28 | }; 29 | -------------------------------------------------------------------------------- /Projects/Abc/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Projects/Abc/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | Abc 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /Projects/Abc/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 5 | org.eclipse.jdt.core.compiler.compliance=1.8 6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 10 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 11 | org.eclipse.jdt.core.compiler.source=1.8 12 | -------------------------------------------------------------------------------- /Projects/Abc/bin/com/apps/beans/Student.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RajkumarSony/HacktoberFest2022/2268dfd80de7213007f1241365eb25e7810710f4/Projects/Abc/bin/com/apps/beans/Student.class -------------------------------------------------------------------------------- /Projects/Abc/bin/com/apps/config/applicationContext.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Projects/Abc/bin/com/apps/test/Client.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RajkumarSony/HacktoberFest2022/2268dfd80de7213007f1241365eb25e7810710f4/Projects/Abc/bin/com/apps/test/Client.class -------------------------------------------------------------------------------- /Projects/Abc/src/com/apps/beans/Student.java: -------------------------------------------------------------------------------- 1 | package com.apps.beans; 2 | 3 | public class Student { 4 | private String message; 5 | 6 | public void setMessage(String message){ 7 | this.message = message; 8 | } 9 | public void getMessage(){ 10 | System.out.println("Your Message : " + message); 11 | } 12 | } -------------------------------------------------------------------------------- /Projects/Abc/src/com/apps/config/applicationContext.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Projects/Abc/src/com/apps/test/Client.java: -------------------------------------------------------------------------------- 1 | package com.apps.test; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.support.ClassPathXmlApplicationContext; 5 | 6 | public class Client { 7 | public static void main(String[] args) { 8 | applicationContex context = new ClasspathXmlapplicationContext("Beans.xml"); 9 | HelloWorld obj = (HelloWorld) context.getBean("helloWorld"); 10 | obj.getMessage(); 11 | } 12 | } -------------------------------------------------------------------------------- /Projects/DynamicForm/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Projects/DynamicForm/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | DynamicForm 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.wst.common.project.facet.core.builder 15 | 16 | 17 | 18 | 19 | org.eclipse.wst.validation.validationbuilder 20 | 21 | 22 | 23 | 24 | 25 | org.eclipse.jem.workbench.JavaEMFNature 26 | org.eclipse.wst.common.modulecore.ModuleCoreNature 27 | org.eclipse.wst.common.project.facet.core.nature 28 | org.eclipse.jdt.core.javanature 29 | org.eclipse.wst.jsdt.core.jsNature 30 | 31 | 32 | -------------------------------------------------------------------------------- /Projects/DynamicForm/.settings/.jsdtscope: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Projects/DynamicForm/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 4 | org.eclipse.jdt.core.compiler.compliance=1.8 5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 7 | org.eclipse.jdt.core.compiler.source=1.8 8 | -------------------------------------------------------------------------------- /Projects/DynamicForm/.settings/org.eclipse.wst.common.component: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Projects/DynamicForm/.settings/org.eclipse.wst.common.project.facet.core.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Projects/DynamicForm/.settings/org.eclipse.wst.jsdt.ui.superType.container: -------------------------------------------------------------------------------- 1 | org.eclipse.wst.jsdt.launching.baseBrowserLibrary -------------------------------------------------------------------------------- /Projects/DynamicForm/.settings/org.eclipse.wst.jsdt.ui.superType.name: -------------------------------------------------------------------------------- 1 | Window -------------------------------------------------------------------------------- /Projects/DynamicForm/WebContent/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Class-Path: 3 | 4 | -------------------------------------------------------------------------------- /Projects/DynamicForm/WebContent/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | DynamicForm 4 | 5 | index.html 6 | index.htm 7 | index.jsp 8 | default.html 9 | default.htm 10 | default.jsp 11 | 12 | 13 | 14 | srv1 15 | EditFormServlet 16 | 17 | 18 | srv1 19 | /editForm 20 | 21 | -------------------------------------------------------------------------------- /Projects/DynamicForm/build/classes/com/spiosys/servlet/EditFormServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RajkumarSony/HacktoberFest2022/2268dfd80de7213007f1241365eb25e7810710f4/Projects/DynamicForm/build/classes/com/spiosys/servlet/EditFormServlet.class -------------------------------------------------------------------------------- /Projects/DynamicForm/build/classes/com/spiosys/servlet/UpdateServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RajkumarSony/HacktoberFest2022/2268dfd80de7213007f1241365eb25e7810710f4/Projects/DynamicForm/build/classes/com/spiosys/servlet/UpdateServlet.class -------------------------------------------------------------------------------- /Projects/DynamicForm/src/com/spiosys/servlet/EditFormServlet.java: -------------------------------------------------------------------------------- 1 | package com.spiosys.servlet; 2 | 3 | import java.io.IOException; 4 | import java.io.PrintWriter; 5 | 6 | import javax.servlet.ServletException; 7 | import javax.servlet.http.HttpServlet; 8 | import javax.servlet.http.HttpServletRequest; 9 | import javax.servlet.http.HttpServletResponse; 10 | 11 | import com.spiosys.factory.StudentServiceFactory; 12 | import com.spiosys.service.StudentService; 13 | import com.spiosys.to.Student; 14 | 15 | 16 | public class EditFormServlet extends HttpServlet { 17 | private static final long serialVersionUID = 1L; 18 | 19 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 20 | 21 | response.setContentType("text/html"); 22 | PrintWriter out = response.getWriter(); 23 | 24 | String sid = request.getParameter("sid"); 25 | 26 | StudentService stdService = StudentServiceFactory.getStudentService(); 27 | Student std = stdService.getStudent(sid); 28 | 29 | if(std == null) { 30 | out.println(""); 31 | out.println(""); 32 | out.println("

Durga Software Solutions

"); 33 | out.println("

Student Updation Status

"); 34 | out.println("

Student Not Existed

"); 35 | out.println("

|Update Form|

'"); 36 | out.println(""); 37 | }else { 38 | out.println(""); 39 | out.println(""); 40 | out.println("

Durga Software Solutions

"); 41 | out.println("

Student Edit Form

"); 42 | out.println("
"); 43 | out.println("
"); 44 | out.println(""); 45 | out.println(""); 46 | out.println(""); 47 | out.println(""); 48 | out.println(""); 49 | out.println(""); 50 | out.println("
Student Id"+sid+"
Student Name
Student Address
"); 51 | } 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /Projects/DynamicForm/src/com/spiosys/servlet/UpdateServlet.java: -------------------------------------------------------------------------------- 1 | package com.spiosys.servlet; 2 | 3 | import java.io.IOException; 4 | import java.io.PrintWriter; 5 | 6 | import javax.servlet.ServletException; 7 | import javax.servlet.http.HttpServlet; 8 | import javax.servlet.http.HttpServletRequest; 9 | import javax.servlet.http.HttpServletResponse; 10 | 11 | import com.spiosys.factory.StudentServiceFactory; 12 | import com.spiosys.service.StudentService; 13 | 14 | 15 | public class UpdateServlet extends HttpServlet { 16 | private static final long serialVersionUID = 1L; 17 | 18 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 19 | 20 | response.setContentType("text/html"); 21 | PrintWriter out = response.getWriter(); 22 | 23 | String sid = request.getParameter("sid"); 24 | String sname = request.getParameter("sname"); 25 | String saddr = request.getParameter("saddr"); 26 | 27 | StudentService stdService = StudentServiceFactory.getStudentService(); 28 | String status = stdService.update(sid, sname, saddr); 29 | 30 | out.println(""); 31 | out.println(""); 32 | out.println("

Durga Software Solutions

"); 33 | out.println("

Student Updation Status

"); 34 | out.println("

"); 35 | 36 | if(status.equals("success")) { 37 | 38 | out.println("Student Updation Success"); 39 | }else { 40 | 41 | out.println("Student Updation Failure"); 42 | } 43 | out.println("

"); 44 | out.println("

|Update Form|

"); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Projects/Hotel Management System/README.md: -------------------------------------------------------------------------------- 1 | # OOP_Project 2 | 3 | # Hotel Management System (C++) 4 | 5 | ### INSTRUCTIONS – 6 | 7 | o Run the main.cpp file 8 | 9 | o Command Line to run the code – 10 | 11 | > g++ main.cpp -l sqlite3 -o main 12 | 13 | > main.exe 14 | 15 | 16 | ##### OBJECTIVE – 17 | The main idea of the objective is to build an environment for storage, collection and retrieval of data from database for hotels. 18 | 19 | ##### REFERENCE – 20 | • Class 12th Python Project which was similar to objective . 21 | 22 | • Geekforgeeks for learning SQLAPI++ and sqlite3. 23 | 24 | ##### INTRODUCTION – 25 | The objective can build an environment for storage, collection and retrieval of data from database for hotels. 26 | 27 | Data is a necessary information that must be stored at some place for any organizations with lot of traffic. Hotel is such an important organization. This data can be used for many purposes such as details, security and also for perks like offers. 28 | 29 | The project will give an environment for such purpose, in this project the authorities can store data with a simple CUI (Character User Interface), Calculate the Rent Amount, Automatically Allot a Free Room, Update the User Details (e.g., check out date, mobile number, etc.), the respective fare will be calculated. And also, if the customer leaves the hotel, his data will automatically shift to a database with old customer details. 30 | 31 | ##### TECHNOLOGY STACK – 32 | SOFTWARE USED – Visual Studio Code 33 | 34 | • The objective is using High Level Language C++ as its base language. 35 | 36 | • In the backend, the data will be stored in Real-Time Database Management System (RDBMS) SQL – Structured Query Language. This can be done by linking SQL with C++ using SQLAPI's sqlite3 package. 37 | 38 | o Primary Key 39 | 40 | o Different Tables for Different Purpose 41 | 42 | • C++ header files 43 | 44 | o bits/stdc++.h – to include all the basic header files 45 | 46 | o ctime – to get the system time information 47 | 48 | o iomanip – to format/manipulate the output (time) 49 | 50 | o string – to use std :: string class 51 | 52 | o files header files – to include different files to clean-up the code and make it more readable. 53 | 54 | • Object Oriented Programming Concepts. 55 | 56 | ### INSTRUCTIONS – 57 | o Run the main.cpp file 58 | 59 | o Command Line to run the code – 60 | 61 | > g++ main.cpp -l sqlite3 -o main 62 | 63 | > main.exe 64 | -------------------------------------------------------------------------------- /Projects/Hotel Management System/add_guest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace std; 8 | 9 | int ID; 10 | int ID1; 11 | 12 | static int callback(void* data, int argc, char** argv, char** colName){ 13 | for(int i=0;i> " << ID << "\n"; 60 | cout << "Enter the Name of Guest ->> "; 61 | fflush(stdin); 62 | getline(cin,name); 63 | fflush(stdin); 64 | cout << "Enter the Address of Guest ->> "; 65 | getline(cin,address); 66 | fflush(stdin); 67 | cout << "Enter the Mobile Number of Guest ->> "; 68 | getline(cin,mobile); 69 | fflush(stdin); 70 | cout << "Enter the Aadhaar Number of Guest ->> "; 71 | getline(cin,aadhar); 72 | fflush(stdin); 73 | cout << "Enter the Check Out Date of Guest (YYYY-MM-DD) ->> "; 74 | getline(cin,check_out_date); 75 | fflush(stdin); 76 | cout << "Enter the Check Out Time of Guest (HH:MM) ->> "; 77 | getline(cin,check_out_time); 78 | fflush(stdin); 79 | cout << "\nEnter The Type of Room Guest wants ->> \n"; 80 | cout << "1. Single ( > 1 ) ->> \n"; 81 | cout << "2. Double ( > 2 ) ->> \n"; 82 | cout << "3. Suite ( > 3 ) ->> \n"; 83 | cout << "4. Murphy ( > 4 ) ->> \n"; 84 | cout << "5. Cabana ( > 5 ) ->> \n"; 85 | cout << "Enter Choice ->> "; 86 | cin >> room_type; 87 | room_type = room_type=="1" ? "SINGLE" : room_type=="2" ? "DOUBLE" : room_type=="3" ? "SUITE" : room_type=="4" ? "MURPHY" : room_type=="5" ? "CABANA" : "0"; 88 | 89 | auto ztime = time(0); 90 | stringstream _time_date, _time_time; 91 | _time_date << put_time(localtime(&ztime), "%Y-%m-%d"); 92 | check_in_date = _time_date.str(); 93 | _time_time << put_time(localtime(&ztime), "%H:%M"); 94 | check_in_time = _time_time.str(); 95 | amount = calculateRent(check_in_date, check_out_date, room_type); 96 | 97 | cout << "Amount Payable ->> Rs." << amount; 98 | cout << "\n\n"; 99 | cout << "Do you want to check in (Y/y)? ->> "; 100 | char choice; 101 | cin >> choice; 102 | if(choice == 'y' || choice == 'Y'){ 103 | room_number = allotRoom(room_type); 104 | cout << "Alloted Room ->> " << room_number; 105 | 106 | Customer C; 107 | C.setData(ID,name,address,mobile,aadhar,check_in_date,check_in_time,check_out_date,check_out_time,room_number,room_type,amount); 108 | 109 | query = C.getData(true); 110 | myCursor = sqlite3_exec(DB, query.c_str(), NULL, 0, &error); 111 | insertion_check(myCursor, error); 112 | } 113 | 114 | sqlite3_close(DB); 115 | return 0; 116 | } -------------------------------------------------------------------------------- /Projects/Hotel Management System/calculate_rent.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | static int rent; 7 | static int callback_get_rent(void* data, int argc, char** argv, char** colName){ 8 | for(int i=0;i> " << nodStay << "\n"; 39 | return nodStay*rent; 40 | } -------------------------------------------------------------------------------- /Projects/Hotel Management System/customer.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | class Customer{ 8 | private: 9 | int createTable(); 10 | int addCustomerDetails(); 11 | int ID,room_number,amount; 12 | string name, address, mobile, aadhar, check_in_date, check_in_time, check_out_date, check_out_time, room_type; 13 | string data; 14 | public: 15 | Customer(bool flag){ 16 | createTable(); 17 | } 18 | Customer(){ 19 | string getData(bool flag); 20 | 21 | void setData(int ID, string name, string address, string mobile, string aadhar, string check_in_date, string check_in_time, string check_out_date, string check_out_time, int room_number, string room_type, int amount); 22 | } 23 | void setData(int ID, string name, string address, string mobile, string aadhar, string check_in_date, string check_in_time, string check_out_date, string check_out_time, int room_number, string room_type, int amount){ 24 | this->ID=ID; 25 | this->name=name; 26 | this->address=address; 27 | this->mobile=mobile; 28 | this->aadhar=aadhar; 29 | this->check_in_date=check_in_date; 30 | this->check_in_time=check_in_time; 31 | this->check_out_date=check_out_date; 32 | this->check_out_time=check_out_time; 33 | this->room_number=room_number; 34 | this->room_type=room_type; 35 | this->amount=amount; 36 | } 37 | string getData(bool flag){ 38 | data = "INSERT INTO AJAX_DB VALUES("+to_string(ID)+", '"+name+"', '"+address+"', '"+mobile+"', '"+aadhar+"', '"+check_in_date+"', '"+check_in_time+"', '"+check_out_date+"', '"+check_out_time+"', "+to_string(room_number)+", '"+room_type+"', "+to_string(amount)+");"; 39 | 40 | return data; 41 | } 42 | }; 43 | 44 | int Customer :: createTable(){ 45 | sqlite3 *DB; 46 | int myCursor = 0; 47 | char *error; 48 | 49 | myCursor = sqlite3_open("AJAX HMS.db", &DB); 50 | //error handling 51 | if(myCursor){ 52 | cerr << "Error While Loading Database!\n"; 53 | cout << sqlite3_errmsg(DB) << "\n"; 54 | return -1; 55 | } 56 | 57 | string query = "CREATE TABLE IF NOT EXISTS AJAX_DB(ID INT PRIMARY KEY NOT NULL, " 58 | "NAME TEXT NOT NULL, " 59 | "ADDRESS TEXT, " 60 | "MOBILE TEXT NOT NULL, " 61 | "AADHAR TEXT NOT NULL, " 62 | "IN_DATE TEXT NOT NULL, " 63 | "IN_TIME TEXT NOT NULL, " 64 | "OUT_DATE TEXT NOT NULL, " 65 | "OUT_TIME TEXT NOT NULL, " 66 | "ROOM_NO INT NOT NULL, " 67 | "ROOM_TYPE TEXT NOT NULL, " 68 | "AMOUNT INT NOT NULL);"; 69 | 70 | myCursor = sqlite3_exec(DB, query.c_str(), NULL, 0, &error); 71 | if(myCursor != SQLITE_OK){ 72 | cerr << "ERROR CREATING CUSTOMER INFORMATION TABLE\n"; 73 | cout << error << "\n"; 74 | sqlite3_free(error); 75 | } 76 | 77 | query = "CREATE TABLE IF NOT EXISTS AJAX_OLD_DB(ID INT PRIMARY KEY NOT NULL, " 78 | "NAME TEXT NOT NULL, " 79 | "ADDRESS TEXT, " 80 | "MOBILE TEXT NOT NULL, " 81 | "AADHAR TEXT NOT NULL, " 82 | "IN_DATE TEXT NOT NULL, " 83 | "IN_TIME TEXT NOT NULL, " 84 | "OUT_DATE TEXT NOT NULL, " 85 | "OUT_TIME TEXT NOT NULL, " 86 | "ROOM_NO INT NOT NULL, " 87 | "ROOM_TYPE TEXT NOT NULL, " 88 | "AMOUNT INT NOT NULL);"; 89 | 90 | myCursor = sqlite3_exec(DB, query.c_str(), NULL, 0, &error); 91 | if(myCursor != SQLITE_OK){ 92 | cerr << "ERROR CREATING CUSTOMER INFORMATION TABLE\n"; 93 | cout << error << "\n"; 94 | sqlite3_free(error); 95 | } 96 | 97 | sqlite3_close(DB); 98 | return 0; 99 | } -------------------------------------------------------------------------------- /Projects/Hotel Management System/insertion_check.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | void insertion_check(int check, char *error){ 8 | if(check != SQLITE_OK){ 9 | cerr << "ERROR INSERTING DATA\n"; 10 | cout << error << "\n"; 11 | } 12 | } -------------------------------------------------------------------------------- /Projects/Hotel Management System/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "insertion_check.cpp" 8 | #include "query_exec.cpp" 9 | #include "room.cpp" 10 | #include "customer.cpp" 11 | #include "room_allotment.cpp" 12 | #include "calculate_rent.cpp" 13 | #include "add_guest.cpp" 14 | #include "update_checkout.cpp" 15 | #include "refresh_db.cpp" 16 | 17 | using namespace std; 18 | 19 | int mainMenu(){ 20 | int choice; 21 | int choice1; 22 | this_thread::sleep_for(chrono::milliseconds(200)); 23 | cout << "\n"; 24 | cout << "1.Add New Guest( > 1 ) ->> \n"; 25 | cout << "2.View Room Specifications( > 2 ) ->> \n"; 26 | cout << "3.Query( > 3 ) ->> \n"; 27 | cout << "4.Update Check Out Time( > 4 ) ->> \n"; 28 | cout << "5.Display Data of Old Customers( > 5 ) ->> \n"; 29 | cout << "6.Refresh Database( > 6 ) ->> \n"; 30 | cout << "7.Clear Screen ( > 7 ) ->> \n"; 31 | cout << "8.Exit( > 8 ) ->> \n"; 32 | cout << "\n"; 33 | cout << "Enter Choice ->> "; 34 | cin >> choice; 35 | cout << "\n"; 36 | switch(choice){ 37 | case 1 : { 38 | cout << "\n"; 39 | addGuest(); 40 | } 41 | break; 42 | case 2 : { 43 | this_thread::sleep_for(chrono::milliseconds(200)); 44 | cout << "\n"; 45 | cout << "--- ROOM SPECIFICATIONS ---\n\n"; 46 | queryExec("SELECT * FROM ROOM_SPECIFICATIONS;"); 47 | } 48 | break; 49 | case 3 : { 50 | int choice1; 51 | this_thread::sleep_for(chrono::milliseconds(200)); 52 | cout.flush(); 53 | cout << "\n"; 54 | cout << "--- QUERY MENU ---\n\n"; 55 | cout << "\n1. Get Guest Details Alphabetically... ( > 1 )->> \n"; 56 | cout << "2. Get Guest Details ID Wise... ( > 2 )->> \n"; 57 | cout << "3. Get Guest Details Check IN Date Wise... ( > 3 )->> \n"; 58 | cout << "4. Get Guest Details Check OUT Date Wise... ( > 4 )->> \n"; 59 | cout << "5. Get Guest Details Room Number Wise... ( > 5 )->> \n"; 60 | cout << "6. Back To Main Menu... ( > 6 )->> \n"; 61 | cout << "\nEnter Choice ->> "; 62 | cin >> choice1; 63 | cout << "\n"; 64 | switch(choice1){ 65 | case 1 : { 66 | // cout << "\n"; 67 | cout << "--- GUEST DETAILS ---\n\n"; 68 | this_thread::sleep_for(chrono::milliseconds(200)); 69 | queryExec("SELECT * FROM AJAX_DB ORDER BY NAME ASC;"); 70 | this_thread::sleep_for(chrono::milliseconds(200)); 71 | } 72 | break; 73 | case 2 : { 74 | int search_ID; 75 | cout << "\n"; 76 | cout << "Enter Guest ID to search ->> "; 77 | cin >> search_ID; 78 | this_thread::sleep_for(chrono::milliseconds(200)); 79 | // cout << "\n"; 80 | cout << "--- GUEST DETAILS ---\n\n"; 81 | this_thread::sleep_for(chrono::milliseconds(200)); 82 | queryExec("SELECT * FROM AJAX_DB WHERE ID = "+to_string(search_ID)+";"); 83 | } 84 | break; 85 | case 3 : { 86 | string search_check_in_date; 87 | cout << "\n"; 88 | cout << "Enter Check IN Date to search (YYYY-MM-DD) ->> "; 89 | cin >> search_check_in_date; 90 | this_thread::sleep_for(chrono::milliseconds(200)); 91 | // cout << "\n"; 92 | cout << "--- GUEST DETAILS ---\n\n"; 93 | this_thread::sleep_for(chrono::milliseconds(200)); 94 | queryExec("SELECT * FROM AJAX_DB WHERE IN_DATE = '"+search_check_in_date+"';"); 95 | } 96 | break; 97 | case 4 : { 98 | string search_check_out_date; 99 | cout << "\n"; 100 | cout << "Enter Check OUT Date to search (YYYY-MM-DD) ->> "; 101 | cin >> search_check_out_date; 102 | this_thread::sleep_for(chrono::milliseconds(200)); 103 | // cout << "\n"; 104 | cout << "--- GUEST DETAILS ---\n\n"; 105 | this_thread::sleep_for(chrono::milliseconds(200)); 106 | queryExec("SELECT * FROM AJAX_DB WHERE OUT_DATE = '"+search_check_out_date+"';"); 107 | } 108 | break; 109 | case 5 : { 110 | int search_rno; 111 | cout << "\n"; 112 | cout << "Enter Room Number to search ->> "; 113 | cin >> search_rno; 114 | this_thread::sleep_for(chrono::milliseconds(200)); 115 | cout << "\n"; 116 | cout << "--- GUEST DETAILS ---\n\n"; 117 | this_thread::sleep_for(chrono::milliseconds(200)); 118 | queryExec("SELECT * FROM AJAX_DB WHERE ROOM_NO = "+to_string(search_rno)+";"); 119 | } 120 | break; 121 | case 6 : //continue 122 | break; 123 | default : cout << "Sorry, Wrong Choice !!!\n"; 124 | } 125 | } 126 | break; 127 | case 4 : { 128 | cout << "\n"; 129 | updateCheckout(); 130 | cout << "\n"; 131 | system("pause"); 132 | } 133 | break; 134 | case 5 : { 135 | this_thread::sleep_for(chrono::milliseconds(200)); 136 | cout << "\n"; 137 | cout <<"--- GUEST DETAILS ---\n\n"; 138 | this_thread::sleep_for(chrono::milliseconds(200)); 139 | queryExec("SELECT * FROM AJAX_OLD_DB;"); 140 | } 141 | break; 142 | case 6 : { 143 | cout << "\n\n"; 144 | refreshDB(); 145 | } 146 | break; 147 | case 7 : system("cls"); 148 | break; 149 | case 8 : { 150 | cout << "\nTHANK YOU "; 151 | this_thread::sleep_for(chrono::milliseconds(200)); 152 | cout << "FOR USING "; 153 | this_thread::sleep_for(chrono::milliseconds(200)); 154 | cout << "CLOUD_9 HOTEL MANAGEMENT SYSTEM !!!\n"; 155 | this_thread::sleep_for(chrono::milliseconds(5000)); 156 | return 1; 157 | } 158 | break; 159 | default : { 160 | cout << "Sorry, Wrong Choice !!!\n"; 161 | system("pause"); 162 | } 163 | break; 164 | } 165 | return 0; 166 | } 167 | 168 | int main(){ 169 | Room R; 170 | Customer C(true); 171 | while(true){ 172 | cout << "\n"; 173 | int exit = mainMenu(); 174 | if(exit) return 0; 175 | } 176 | } -------------------------------------------------------------------------------- /Projects/Hotel Management System/main.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RajkumarSony/HacktoberFest2022/2268dfd80de7213007f1241365eb25e7810710f4/Projects/Hotel Management System/main.exe -------------------------------------------------------------------------------- /Projects/Hotel Management System/query_exec.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | class Data_Query{ 9 | private: 10 | vector column_names; 11 | vector > query_data; 12 | public: 13 | void setData(string value, string col){ 14 | int temp=0; 15 | // cout << value << " " << col << "\n"; 16 | for(int i=0;i 2 | #include 3 | 4 | using namespace std; 5 | 6 | static int callback_test(void *data, int argc, char **argv, char **colName){ 7 | cout << argc; 8 | for (int i = 0; i < argc; i++){ 9 | cout << colName[i] << " - " << argv[i]; 10 | } 11 | // D.getData(); 12 | return 0; 13 | } 14 | 15 | int refreshDB(){ 16 | auto ztime = time(0); 17 | stringstream _time_date, _time_time; 18 | _time_date << put_time(localtime(&ztime), "%Y-%m-%d"); 19 | string cur_date = _time_date.str(); 20 | _time_time << put_time(localtime(&ztime), "%H:%M"); 21 | string cur_time = _time_time.str(); 22 | 23 | // cout << cur_date << " " << cur_time; 24 | sqlite3 *DB; 25 | int myCursor = 0; 26 | char *error; 27 | 28 | myCursor = sqlite3_open("AJAX HMS.db", &DB); 29 | //error handling 30 | if(myCursor){ 31 | cerr << "Error While Loading Database!\n"; 32 | cout << sqlite3_errmsg(DB) << "\n"; 33 | return -1; 34 | } 35 | 36 | string query; 37 | query = "INSERT INTO AJAX_OLD_DB SELECT * FROM AJAX_DB WHERE '"+cur_date+"' > OUT_DATE;"; 38 | myCursor = sqlite3_exec(DB, query.c_str(), NULL, NULL, &error); 39 | insertion_check(myCursor, error); 40 | 41 | query = "DELETE FROM AJAX_DB WHERE '"+cur_date+"' > OUT_DATE;"; 42 | myCursor = sqlite3_exec(DB, query.c_str(), NULL, NULL, &error); 43 | 44 | string refreshing = "R E F R E S H I N G . . ."; 45 | for(int i=0;i 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | // void insertion_check(int check, char *error){ 8 | // if(check != SQLITE_OK){ 9 | // cerr << "ERROR INSERTING DATA\n"; 10 | // cout << error << "\n"; 11 | // } 12 | // } 13 | 14 | class Room{ 15 | private: 16 | int addRoomInfoToDB(); 17 | int addRoomInfoToDB(bool isData, sqlite3* DB); 18 | public: 19 | Room(){ 20 | addRoomInfoToDB(); 21 | } 22 | }; 23 | 24 | int Room :: addRoomInfoToDB(bool isData, sqlite3 *DB){ 25 | if(true){ 26 | int myCursor = 0; 27 | char *error; 28 | string query; 29 | 30 | query = "INSERT INTO ROOM_SPECIFICATIONS VALUES('AJAX1', 'SINGLE', 1, 'YES', 'YES', 'NO', 'NO', 3000);"; 31 | // query = "INSERT INTO ROOM_SPECIFICATIONS (ID, TYPE, BEDS, AC, WiFi, AI, POOL, RENT) SELECT 'AJAX1', 'SINGLE', 1, 'YES', 'YES', 'NO', 'NO', 3000 FROM ROOM_SPECIFICATIONS WHERE NOT EXISTS(SELECT * FROM ROOM_SPECIFICATIONS WHERE ID = 'AJAX1');"; 32 | myCursor = sqlite3_exec(DB, query.c_str(), NULL, 0, &error); 33 | insertion_check(myCursor, error); 34 | 35 | query = "INSERT INTO ROOM_SPECIFICATIONS VALUES('AJAX2', 'DOUBLE', 2, 'YES', 'YES', 'NO', 'NO', 4500);"; 36 | // query = "INSERT INTO ROOM_SPECIFICATIONS (ID, TYPE, BEDS, AC, WiFi, AI, POOL, RENT) SELECT 'AJAX2', 'DOUBLE', 2, 'YES', 'YES', 'NO', 'NO', 4500 FROM ROOM_SPECIFICATIONS WHERE NOT EXISTS(SELECT * FROM ROOM_SPECIFICATIONS WHERE ID = 'AJAX2');"; 37 | myCursor = sqlite3_exec(DB, query.c_str(), NULL, 0, &error); 38 | insertion_check(myCursor, error); 39 | 40 | query = "INSERT INTO ROOM_SPECIFICATIONS VALUES('AJAX3', 'SUITE', 2, 'YES', 'YES', 'YES', 'NO', 6000);"; 41 | // query = "INSERT INTO ROOM_SPECIFICATIONS (ID, TYPE, BEDS, AC, WiFi, AI, POOL, RENT) SELECT 'AJAX3', 'SUITE', 2, 'YES', 'YES', 'YES', 'NO', 6000 FROM ROOM_SPECIFICATIONS WHERE NOT EXISTS(SELECT * FROM ROOM_SPECIFICATIONS WHERE ID = 'AJAX3');"; 42 | myCursor = sqlite3_exec(DB, query.c_str(), NULL, 0, &error); 43 | insertion_check(myCursor, error); 44 | 45 | query = "INSERT INTO ROOM_SPECIFICATIONS VALUES('AJAX4', 'MURPHY', 4, 'YES', 'YES', 'YES', 'NO', 8000);"; 46 | // query = "INSERT INTO ROOM_SPECIFICATIONS (ID, TYPE, BEDS, AC, WiFi, AI, POOL, RENT) SELECT 'AJAX4', 'MURPHY', 4, 'YES', 'YES', 'YES', 'NO', 8000 FROM ROOM_SPECIFICATIONS WHERE NOT EXISTS(SELECT * FROM ROOM_SPECIFICATIONS WHERE ID = 'AJAX4');"; 47 | myCursor = sqlite3_exec(DB, query.c_str(), NULL, 0, &error); 48 | insertion_check(myCursor, error); 49 | 50 | query = "INSERT INTO ROOM_SPECIFICATIONS VALUES('AJAX5', 'CABANA', 2, 'YES', 'YES', 'YES', 'YES', 10000);"; 51 | // query = "INSERT INTO ROOM_SPECIFICATIONS (ID, TYPE, BEDS, AC, WiFi, AI, POOL, RENT) SELECT 'AJAX5', 'CABANA', 2, 'YES', 'YES', 'YES', 'YES', 10000 FROM ROOM_SPECIFICATIONS WHERE NOT EXISTS(SELECT * FROM ROOM_SPECIFICATIONS WHERE ID = 'AJAX5');"; 52 | myCursor = sqlite3_exec(DB, query.c_str(), NULL, 0, &error); 53 | insertion_check(myCursor, error); 54 | 55 | system("cls"); 56 | 57 | } 58 | return 0; 59 | } 60 | 61 | int Room :: addRoomInfoToDB(){ 62 | sqlite3 *DB; 63 | int myCursor = 0; 64 | char *error; 65 | myCursor = sqlite3_open("AJAX HMS.db", &DB); 66 | 67 | if(myCursor){ 68 | cerr << "Error While Loading Database!\n"; 69 | cout << sqlite3_errmsg(DB) << "\n"; 70 | return -1; 71 | } 72 | 73 | string query = "CREATE TABLE IF NOT EXISTS ROOM_SPECIFICATIONS(ID TEXT PRIMARY KEY NOT NULL, " 74 | "TYPE TEXT NOT NULL, BEDS INT NOT NULL, " 75 | "AC TEXT NOT NULL, WiFi TEXT NOT NULL, " 76 | "AI TEXT NOT NULL, POOL TEXT NOT NULL, " 77 | "RENT INT NOT NULL);"; 78 | 79 | myCursor = sqlite3_exec(DB, query.c_str(), NULL, 0, &error); 80 | 81 | if(myCursor != SQLITE_OK){ 82 | cerr << "ERROR CREATING ROOM SPECIFICATION TABLE\n"; 83 | cout << error << "\n"; 84 | sqlite3_free(error); 85 | } 86 | 87 | addRoomInfoToDB(true, DB);//insert values in database 88 | 89 | cout << "Successfully Created/Loaded Hotel Management System Environment!\n\n"; 90 | this_thread::sleep_for(chrono::milliseconds(200)); 91 | cout << setw(60) << "--- HOTEL DETAILS ---\n"; 92 | this_thread::sleep_for(chrono::milliseconds(200)); 93 | cout << setw(60) << "--- HOTEL CLOUD_9 ---\n"; 94 | this_thread::sleep_for(chrono::milliseconds(200)); 95 | cout << setw(72) << "--- THE HOTEL IS SITUATED UP ABOVE IN SPACE ---\n"; 96 | this_thread::sleep_for(chrono::milliseconds(200)); 97 | cout << setw(88) << "--- THE MODE OF GOING TO HOTEL IS BY INTERGALECTIAL LIFT DEVELOPED BY SPACEX ---\n"; 98 | this_thread::sleep_for(chrono::milliseconds(200)); 99 | cout << setw(74) << "--- THE HOTEL IS FULLY ARTIFICIAL INTELLIGENCE ---\n"; 100 | this_thread::sleep_for(chrono::milliseconds(200)); 101 | cout << setw(68) << "--- THERE ARE SO MANY OTHER FEATURES ---\n"; 102 | this_thread::sleep_for(chrono::milliseconds(200)); 103 | sqlite3_close(DB); 104 | return 0; 105 | } -------------------------------------------------------------------------------- /Projects/Hotel Management System/room_allotment.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | int count_=0; 8 | static int callback_get_count(void* data, int argc, char** argv, char** colName){ 9 | for(int i=0;i room_numbers; 16 | static int callback_get_rooms(void* data, int argc, char** argv, char** colName){ 17 | for(int i=0;i= 2) 55 | return room_numbers[i]+1; 56 | } 57 | return room_numbers[room_numbers.size()-1]+1; 58 | } 59 | } -------------------------------------------------------------------------------- /Projects/Hotel Management System/update_checkout.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | class CallBack{ 7 | private: 8 | string initialDate; 9 | string roomType; 10 | int amt; 11 | public: 12 | void setDate(string initialDate){ 13 | this->initialDate = initialDate; 14 | } 15 | string getDate(){ 16 | return initialDate; 17 | } 18 | void setRoomType(string roomType){ 19 | this->roomType = roomType; 20 | } 21 | string getRoomType(){ 22 | return roomType; 23 | } 24 | void setAmount(int amt){ 25 | this->amt = amt; 26 | } 27 | int getAmount(){ 28 | return amt; 29 | } 30 | 31 | }; 32 | 33 | CallBack C; 34 | static int exit_; 35 | static int callback_get_initalDate(void *data, int argc, char **argv, char **colName){ 36 | if (argc == 0){ 37 | exit_=-1; 38 | return -1; 39 | } 40 | for (int i = 0; i < argc; i++){ 41 | C.setDate(argv[i]); 42 | } 43 | // D.getData(); 44 | return 0; 45 | } 46 | 47 | static int callback_get_roomType(void *data, int argc, char **argv, char **colName){ 48 | for (int i = 0; i < argc; i++){ 49 | C.setRoomType(argv[i]); 50 | } 51 | // D.getData(); 52 | return 0; 53 | } 54 | 55 | static int callback_get_initialAmount(void *data, int argc, char **argv, char **colName){ 56 | for (int i = 0; i < argc; i++){ 57 | C.setAmount(stoi(argv[i])); 58 | } 59 | // D.getData(); 60 | return 0; 61 | } 62 | 63 | int count__=0; 64 | static int callback_get_count1(void* data, int argc, char** argv, char** colName){ 65 | for(int i=0;i> "; 86 | cin >> rno; 87 | string query; 88 | 89 | query = "SELECT COUNT (ALL) FROM AJAX_DB WHERE ROOM_NO = "+to_string(rno)+";"; 90 | myCursor = sqlite3_exec(DB, query.c_str(), callback_get_count1, NULL, NULL); 91 | if(count__==0){ 92 | cout << "No Guest Found\n"; 93 | return 0; 94 | } 95 | 96 | query = "SELECT OUT_DATE FROM AJAX_DB WHERE ROOM_NO = "+to_string(rno)+";"; 97 | myCursor = sqlite3_exec(DB, query.c_str(), callback_get_initalDate, NULL, NULL); 98 | 99 | query = "SELECT ROOM_TYPE FROM AJAX_DB WHERE ROOM_NO = "+to_string(rno)+";"; 100 | myCursor = sqlite3_exec(DB, query.c_str(), callback_get_roomType, NULL, NULL); 101 | 102 | query = "SELECT AMOUNT FROM AJAX_DB WHERE ROOM_NO = "+to_string(rno)+";"; 103 | myCursor = sqlite3_exec(DB, query.c_str(), callback_get_initialAmount, NULL, NULL); 104 | 105 | string newDate; 106 | cout << "Enter New Check-out Date (YYYY-MM-DD) ->> "; 107 | cin >> newDate; 108 | 109 | string newTime; 110 | cout << "Enter New Check-out Time (HH:MM) ->> "; 111 | cin >> newTime; 112 | 113 | int newAmount = calculateRent(C.getDate(),newDate,C.getRoomType()); 114 | 115 | //YYYY-MM-DD 116 | int days, months, years; 117 | days = stoi(newDate.substr(8,10)) - stoi(C.getDate().substr(8,10)); 118 | months = stoi(newDate.substr(5,7)) - stoi(C.getDate().substr(5,7)); 119 | years = stoi(newDate.substr(0,4)) - stoi(C.getDate().substr(0,4)); 120 | 121 | int nodStay = days + months*30 + years*12*30; 122 | 123 | char choice; 124 | cout << "Extra Amount To Pay For " << nodStay << " Days ->> Rs. " << newAmount << "\n"; 125 | cout << "Do You Want To Confirm? (Y/y) ->> "; 126 | cin >> choice; 127 | 128 | int totalAmount = newAmount+C.getAmount(); 129 | 130 | if(choice == 'Y' || choice == 'y'){ 131 | query = "UPDATE AJAX_DB SET OUT_DATE = '"+newDate+"', OUT_TIME = '"+newTime+"', AMOUNT = "+to_string(totalAmount)+" WHERE ROOM_NO = "+to_string(rno)+";"; 132 | char *error; 133 | myCursor = sqlite3_exec(DB, query.c_str(),NULL,NULL,&error); 134 | insertion_check(myCursor, error); 135 | cout << "DATA UPDATED SUCCESSFULLY !!!"; 136 | } 137 | sqlite3_close(DB); 138 | return 0; 139 | } -------------------------------------------------------------------------------- /Projects/Lbraray Management System/LMS BY Krishnika/README.md: -------------------------------------------------------------------------------- 1 | The Library Management System the system designed to be used by the library admin and the Users. 2 | 3 | Techniques used: 4 | 1. linked list 5 | 2. array 6 | 7 | The system developed by Krishnika Gupta. 8 | 9 | PIN TO ACESS IT IS : krishna@123 10 | -------------------------------------------------------------------------------- /Projects/Lbraray Management System/LMS BY Krishnika/mainprogram.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | /*The Library Management System 8 | the system designed to be used by the library admin and the Users 9 | 10 | Techniques used: 11 | 1. linked list 12 | 2. array 13 | 14 | 15 | /*declare the linked list variables*/ 16 | struct UserRecord { // this struct will hold User details 17 | string UID; 18 | string UName; 19 | string Phone; 20 | int BorrowNo; 21 | int ReturnNo; 22 | string BorrowingBook[3][5]; 23 | string ReturningBook[15][5]; 24 | UserRecord* Next; 25 | }; 26 | struct BookRecord { 27 | string bID; 28 | string btitle; 29 | string category; 30 | string genre; 31 | bool availability; 32 | BookRecord* Next2; 33 | }; 34 | 35 | 36 | UserRecord* Head = NULL; 37 | BookRecord* Head2 = NULL; 38 | int place = 0, place2 = 0, posi = 0; 39 | char choice, option1, option2; 40 | int position; 41 | 42 | string Booktitle, bcateg, bgenre, borrowdate, bkid, UID; 43 | 44 | string UIDInput; 45 | string UNameInput; 46 | string PhoneInput; 47 | string BorrowingBookInput[3][5]; 48 | string ReturningBookInput[15][5]; 49 | int BorrowNoInput; 50 | 51 | string bIDInput; 52 | string btitleInput; 53 | string categoryInput; 54 | string genreInput; 55 | bool availabilityInput; 56 | 57 | string genre1 = "Drama"; 58 | string genre2 = "Romance"; 59 | string genre3 = "Historical"; 60 | string genre4 = "Realistic"; 61 | string genre5 = "Fan"; 62 | string genre6 = "Narrative"; 63 | string genre7 = "Biography"; 64 | string genre8 = "Periodicals"; 65 | string genre9 = "Self-help"; 66 | string genre10 = "Reference"; 67 | string category1 = "Fiction"; 68 | string category2 = "Non-Fiction"; 69 | 70 | void SignIn(); 71 | void AddBook(); 72 | void AddUser(); 73 | void DisplayBook(BookRecord* Head); 74 | void DisplayBookA(BookRecord* Head); 75 | BookRecord* SearchBook(string title, BookRecord* Head); 76 | bool searchU(string UID, UserRecord* Head); 77 | bool Searchb(string bid, BookRecord* Head); 78 | void returnbook(); 79 | void borrowBook(string biD, BookRecord* Head2); 80 | void borrowbooku(string biD, UserRecord* Head); 81 | void searchURecord(UserRecord* Head); 82 | void UlastborrowedB(UserRecord* Head); 83 | BookRecord* UpdateBook(string biD, BookRecord* Head); 84 | void UpdateUInfo(); 85 | void DisplayUsers(UserRecord* Head); 86 | void linkedlistU(string Userid, string UName, string phone, int index); 87 | void linkedlistb(string bid, string Btitle, string bcategory, string bgerne, bool avaiable, int index); 88 | 89 | /*insert new record arbitrary for User */ 90 | void linkedlistU(string Userid, string UName, string phone, int index) 91 | { 92 | UserRecord* New_node = new UserRecord; 93 | New_node->UID = Userid; 94 | New_node->UName = UName; 95 | New_node->Phone = phone; 96 | New_node->BorrowNo = 0; 97 | New_node->ReturnNo = 0; 98 | if (index <= place) { 99 | if (index == 0) { 100 | UserRecord* Position = new UserRecord; 101 | Position->UID = Userid; 102 | Position->UName = UName; 103 | Position->Phone = phone; 104 | Position->BorrowNo = 0; 105 | Position->ReturnNo = 0; 106 | Position->Next = Head; 107 | Head = Position;} 108 | else if (index == place) { 109 | UserRecord* Position2 = new UserRecord; 110 | Position2->UID = Userid; 111 | Position2->UName = UName; 112 | Position2->Phone = phone; 113 | Position2->BorrowNo = 0; 114 | Position2->ReturnNo = 0; 115 | Position2->Next = NULL; 116 | if (Head == NULL) 117 | Head = Position2; 118 | else { 119 | UserRecord* MyCurrent1 = Head; 120 | while (MyCurrent1->Next != NULL) { 121 | MyCurrent1 = MyCurrent1->Next; 122 | } 123 | MyCurrent1->Next = Position2; 124 | } 125 | } 126 | else { 127 | UserRecord* new_record = new UserRecord; 128 | new_record->UID = Userid; 129 | new_record->UName = UName; 130 | new_record->Phone = phone; 131 | new_record->BorrowNo = 0; 132 | new_record->ReturnNo = 0; 133 | UserRecord* prev = Head; 134 | for (int i = 0; i < index - 1; i++) 135 | prev = prev->Next; 136 | new_record->Next = prev->Next; 137 | prev->Next = new_record; 138 | } 139 | } 140 | else if (index > place) 141 | { 142 | UserRecord* Position2 = new UserRecord; 143 | Position2->UID = Userid; 144 | Position2->UName = UName; 145 | Position2->Phone = phone; 146 | Position2->BorrowNo = 0; 147 | Position2->ReturnNo = 0; 148 | Position2->Next = NULL; 149 | if (Head == NULL) { 150 | Head = Position2; 151 | } 152 | else { 153 | UserRecord* MyCurrent1 = Head; 154 | while (MyCurrent1->Next != NULL) { 155 | MyCurrent1 = MyCurrent1->Next;} 156 | MyCurrent1->Next = Position2; 157 | } 158 | } 159 | } 160 | 161 | void linkedlistb(string bid, string Btitle, string bcategory, string bgerne, bool avaiable, int index){ 162 | BookRecord* New_node = new BookRecord; 163 | New_node->bID = bid; 164 | New_node->btitle = Btitle; 165 | New_node->category = bcategory; 166 | New_node->genre = bgerne; 167 | New_node->availability = avaiable; 168 | if (index <= place2) { 169 | if (index == 0) { 170 | BookRecord* Position = new BookRecord; 171 | Position->bID = bid; 172 | Position->btitle = Btitle; 173 | Position->category = bcategory; 174 | Position->genre = bgerne; 175 | Position->availability = avaiable; 176 | Position->Next2 = Head2; 177 | Head2 = Position; 178 | } 179 | 180 | else if (index == place2) 181 | { 182 | BookRecord* Position2 = new BookRecord; //create new node 183 | Position2->bID = bid; 184 | Position2->btitle = Btitle; 185 | Position2->category = bcategory; 186 | Position2->genre = bgerne; 187 | Position2->availability = avaiable; 188 | Position2->Next2 = NULL; 189 | if (Head2 == NULL) 190 | Head2 = Position2; 191 | else { 192 | BookRecord* MyCurrent1 = Head2; 193 | while (MyCurrent1->Next2 != NULL) { 194 | MyCurrent1 = MyCurrent1->Next2; 195 | } 196 | MyCurrent1->Next2 = Position2; 197 | } 198 | } 199 | 200 | else { 201 | BookRecord* new_record = new BookRecord; 202 | new_record->bID = bid; 203 | new_record->btitle = Btitle; 204 | new_record->category = bcategory; 205 | new_record->genre = bgerne; 206 | new_record->availability = avaiable; 207 | BookRecord* prev = Head2; 208 | for (int i = 0; i < index - 1; i++) 209 | prev = prev->Next2; 210 | new_record->Next2 = prev->Next2; 211 | prev->Next2 = new_record; 212 | } 213 | } 214 | 215 | else if (index > place2){ 216 | BookRecord* Position2 = new BookRecord; // create new recode 217 | Position2->bID = bid; 218 | Position2->btitle = Btitle; 219 | Position2->category = bcategory; 220 | Position2->genre = bgerne; 221 | Position2->availability = avaiable; 222 | Position2->Next2 = NULL; 223 | if (Head2 == NULL) { 224 | Head2 = Position2; // insert at the beginning of the linked list 225 | } 226 | else { 227 | BookRecord* MyCurrent1 = Head2; 228 | while (MyCurrent1->Next2 != NULL) { 229 | MyCurrent1 = MyCurrent1->Next2; 230 | } 231 | MyCurrent1->Next2 = Position2; 232 | } 233 | } 234 | } 235 | 236 | /*display record info*/ 237 | void DisplayBook(BookRecord* Head) { 238 | BookRecord* MyCurrent1 = Head; 239 | if (MyCurrent1 == NULL) {/*checking if the linked list is empty or not*/ 240 | cout << "NO recode yet!!, please insert new recodes first..." << endl;} 241 | while (MyCurrent1 != NULL) { /*displaying the inserted nodes*/ 242 | cout << " Book ID : " << MyCurrent1->bID << endl; 243 | cout << " Book title : " << MyCurrent1->btitle << endl; 244 | cout << " Book category : " << MyCurrent1->category << endl; 245 | cout << " Book Genre : " << MyCurrent1->genre << endl; 246 | cout << " Book availability(1=True & 0= False) : " << MyCurrent1->availability << endl; 247 | cout << "|------------------------------------------------------------------|" << endl; 248 | MyCurrent1 = MyCurrent1->Next2;// go to next 249 | } 250 | } 251 | /*display Users records with the active borrowed books*/ 252 | void DisplayUsers(UserRecord* Head) { 253 | UserRecord* MyCurrent1 = Head; 254 | if (MyCurrent1 == NULL) { 255 | cout << "NO recode yet!!, please insert new recodes first..." << endl; 256 | } 257 | while (MyCurrent1 != NULL) { 258 | cout << " User ID : " << MyCurrent1->UID << endl; 259 | cout << " User Name : " << MyCurrent1->UName << endl; 260 | cout << " User Phone NO : " << MyCurrent1->Phone << endl; 261 | cout << " Number of borrowed book: " << MyCurrent1->BorrowNo << endl; 262 | cout << " The borrowed books: \n"<BorrowNo; i++) 264 | { 265 | cout << " Book ID : " << MyCurrent1->BorrowingBook[i][0] << endl; 266 | cout << " Book title : " << MyCurrent1->BorrowingBook[i][1] << endl; 267 | cout << " Book category : " << MyCurrent1->BorrowingBook[i][2] << endl; 268 | cout << " Book Genre : " << MyCurrent1->BorrowingBook[i][3] << endl; 269 | cout << " Borrow Date : " << MyCurrent1->BorrowingBook[i][4] << endl; 270 | cout << "|------------------------------------------------|" << endl; 271 | } 272 | MyCurrent1 = MyCurrent1->Next;// go to next 273 | } 274 | } 275 | /*display last 10 borrowed book*/ 276 | void UlastborrowedB(UserRecord* Head) { 277 | UserRecord* MyCurrent1 = Head; 278 | string name; 279 | cout << "\nEnter User Name or ID: "; cin >> name; 280 | if (MyCurrent1 == NULL) { 281 | cout << "NO recode yet!!, please insert new recodes first..." << endl; 282 | } 283 | while (MyCurrent1 != NULL) { 284 | if (name == MyCurrent1->UName || name == MyCurrent1->UID) { 285 | cout << " User ID : " << MyCurrent1->UID << endl; 286 | cout << " User Name : " << MyCurrent1->UName << endl; 287 | cout << " User Phone NO : " << MyCurrent1->Phone << endl; 288 | cout << " Number of borrowed book: " << MyCurrent1->BorrowNo << endl; 289 | cout << " The borrowed books: \n" << endl; 290 | for (int i = 0; i < MyCurrent1->ReturnNo; i++) 291 | { 292 | if (i ==10) 293 | { 294 | break; 295 | } 296 | cout << " Book ID : " << MyCurrent1->ReturningBook[i][0] << endl; 297 | cout << " Book title : " << MyCurrent1->ReturningBook[i][1] << endl; 298 | cout << " Book category : " << MyCurrent1->ReturningBook[i][2] << endl; 299 | cout << " Book Genre : " << MyCurrent1->ReturningBook[i][3] << endl; 300 | cout << " Borrow Date : " << MyCurrent1->ReturningBook[i][4] << endl; 301 | cout << "|------------------------------------------------|" << endl; 302 | } 303 | break; 304 | } 305 | else 306 | { 307 | MyCurrent1 = MyCurrent1->Next;// go to next 308 | } 309 | } 310 | } 311 | /*search User record*/ 312 | void searchURecord(UserRecord* Head) { 313 | UserRecord* MyCurrent1 = Head; 314 | string sname; 315 | cout << "\nEnter User Name or ID: "; cin >> sname; 316 | if (MyCurrent1 == NULL) { 317 | cout << "NO recode yet!!, please insert new recodes first..." << endl;} 318 | while (MyCurrent1 != NULL) { 319 | if (sname == MyCurrent1->UName || sname == MyCurrent1->UID) { 320 | cout << " User ID : " << MyCurrent1->UID << endl; 321 | cout << " User Name : " << MyCurrent1->UName << endl; 322 | cout << " User Phone NO : " << MyCurrent1->Phone << endl; 323 | cout << " Number of borrowed book: " << MyCurrent1->BorrowNo << endl; 324 | cout << " The borrowed books: \n" << endl; 325 | for (int i = 0; i < MyCurrent1->BorrowNo; i++) 326 | { 327 | cout << " Book ID : " << MyCurrent1->BorrowingBook[i][0] << endl; 328 | cout << " Book title : " << MyCurrent1->BorrowingBook[i][1] << endl; 329 | cout << " Book category : " << MyCurrent1->BorrowingBook[i][2] << endl; 330 | cout << " Book Genre : " << MyCurrent1->BorrowingBook[i][3] << endl; 331 | cout << " Borrow Date : " << MyCurrent1->BorrowingBook[i][4] << endl; 332 | cout << "|------------------------------------------------|" << endl; 333 | } 334 | break; 335 | } 336 | else 337 | { 338 | MyCurrent1 = MyCurrent1->Next;// go to next 339 | } 340 | } 341 | } 342 | /*display the avaiable books*/ 343 | void DisplayBookA(BookRecord* Head) { 344 | BookRecord* MyCurrent1 = Head; 345 | if (MyCurrent1 == NULL) { 346 | cout << "NO recode yet!!, please insert new recodes first..." << endl; 347 | } 348 | while (MyCurrent1 != NULL) { 349 | if (MyCurrent1->availability == true) { 350 | 351 | cout << " Book ID : " << MyCurrent1->bID << endl; 352 | cout << " Book title : " << MyCurrent1->btitle << endl; 353 | cout << " Book category : " << MyCurrent1->category << endl; 354 | cout << " Book Genre : " << MyCurrent1->genre << endl; 355 | cout << " Book availability(1=True & 0= False) : " << MyCurrent1->availability << endl; 356 | } 357 | cout << "|-------------------------------------------------------------------------|" << endl; 358 | MyCurrent1 = MyCurrent1->Next2;// go to next 359 | } 360 | } 361 | /*search book*/ 362 | BookRecord* SearchBook(string title, BookRecord* Head) { 363 | BookRecord* MyCurrent = Head; 364 | if (MyCurrent == NULL) { 365 | cout << "NO recode yet!!, please insert new recodes first..." << endl; 366 | } 367 | while (MyCurrent != NULL) { 368 | if (MyCurrent->btitle == title|| MyCurrent->genre == title|| MyCurrent->category == title || MyCurrent->availability == true) { 369 | cout << " Book ID : " << MyCurrent->bID << endl; 370 | cout << " Book title : " << MyCurrent->btitle << endl; 371 | cout << " Book category : " << MyCurrent->category << endl; 372 | cout << " Book Genre : " << MyCurrent->genre << endl; 373 | cout << " Book availability(1=True & 0= False) : " << MyCurrent->availability << endl; 374 | cout << "|-------------------------------------------------------------------------|" << endl; 375 | return MyCurrent; 376 | } 377 | else { 378 | MyCurrent = MyCurrent->Next2; //go to next record 379 | } 380 | } 381 | return NULL; 382 | } 383 | 384 | /*search the avaiability*/ 385 | bool Searchb(string bid, BookRecord* Head) 386 | { 387 | BookRecord* MyCurrent = Head; 388 | while (MyCurrent != NULL) { 389 | if (MyCurrent->bID == bid) { 390 | return true; 391 | } 392 | else { 393 | MyCurrent = MyCurrent->Next2; //go to next record 394 | } 395 | } 396 | return false; 397 | } 398 | 399 | /*search function for User */ 400 | bool searchU(string UID, UserRecord* Head) 401 | { 402 | UserRecord* MyCurrent = Head; 403 | while (MyCurrent != NULL) { 404 | if (MyCurrent->UID == UID) { 405 | return true; 406 | } 407 | else { 408 | MyCurrent = MyCurrent->Next; //go to next record 409 | } 410 | } 411 | return false; 412 | } 413 | /*update the book record*/ 414 | BookRecord* UpdateBook(string biD, BookRecord* Head) { 415 | BookRecord* MyCurrent1 = Head; 416 | string Booktitle, bcategory, bgenre; 417 | while (MyCurrent1 != NULL) { 418 | if (MyCurrent1->bID == biD) { 419 | getchar(); 420 | cout << "Enter Book title: "; 421 | getline(cin, Booktitle, '\n'); 422 | cout << "Enter Book Category(1. Fiction 2. Non-Fiction): "; cin >> option1; 423 | if (option1 == '1') { 424 | bcategory = category1; 425 | cout << "\nBook genres: "; 426 | cout << "1. Drama 2. Romance 3. Historical 4. Realistic 5. Fan\nEnter one option: "; 427 | cin >> option2; 428 | if (option2 == '1') { 429 | bgenre = genre1; 430 | } 431 | else if (option2 == '2') { 432 | bgenre = genre2; 433 | } 434 | else if (option2 == '3') { 435 | bgenre = genre3; 436 | } 437 | else if (option2 == '4') { 438 | bgenre = genre4; 439 | } 440 | else { 441 | bgenre = genre5; 442 | } 443 | } 444 | else { 445 | bcategory = category2; 446 | cout << "Book genres: "; 447 | cout << "1. Drama 2. Romance 3. Historical 4. Realistic 5. Fan\nEnter one option: "; 448 | cin >> option2; 449 | if (option2 == '1') { 450 | bgenre = genre6; 451 | } 452 | else if (option2 == '2') { 453 | bgenre = genre7; 454 | } 455 | else if (option2 == '3') { 456 | bgenre = genre8; 457 | } 458 | else if (option2 == '4') { 459 | bgenre = genre9; 460 | } 461 | else { 462 | bgenre = genre10; 463 | } 464 | } 465 | MyCurrent1->btitle = Booktitle; 466 | MyCurrent1->category = bcategory; 467 | MyCurrent1->genre = bgenre; 468 | cout << "The New Details" << endl; 469 | cout << " Book ID : " << MyCurrent1->bID << endl; 470 | cout << " Book title : " << MyCurrent1->btitle << endl; 471 | cout << " Book category : " << MyCurrent1->category << endl; 472 | cout << " Book Genre : " << MyCurrent1->genre << endl; 473 | cout << " Book availability(1=True & 0= False) : " << MyCurrent1->availability << endl; 474 | cout << "|-------------------------------------------------------------------------|" << endl; 475 | return MyCurrent1; 476 | } 477 | else 478 | MyCurrent1 = MyCurrent1->Next2; 479 | } 480 | return NULL; 481 | } 482 | /*update User info*/ 483 | void UpdateUInfo() 484 | { 485 | UserRecord* MyCurrent = Head; 486 | cout << "Enter User ID: "; cin >> UIDInput; 487 | while (MyCurrent != NULL) { 488 | if (MyCurrent->UID == UIDInput) { 489 | cout << "\nPlease fill up The new info: \n" << endl; 490 | getchar(); 491 | cout << "Enter User Name: "; getline(cin, UNameInput, '\n'); 492 | cout << "Enter Phone No : "; getline(cin, PhoneInput, '\n'); 493 | MyCurrent->UName = UNameInput; 494 | MyCurrent->Phone = PhoneInput; 495 | break; 496 | } 497 | else { 498 | MyCurrent = MyCurrent->Next; 499 | } 500 | } 501 | return; 502 | } 503 | /*borrow a book*/ 504 | void borrowbooku(string UID, UserRecord* Head) { 505 | UserRecord* MyCurrent2 = Head; 506 | while (MyCurrent2 != NULL){ 507 | if (MyCurrent2->BorrowNo >=3) { 508 | cout << "\n The User has reached the maximum number of borrowing books(which is 3 books)\n"; 509 | cout << "\nNoted: The User may return one of the borrowed book to be able to borrow a new book\n"; 510 | break;} 511 | if (MyCurrent2->UID == UID) { 512 | cout << "\nNote: return the book within 15 days after the borrowing date!\n"; 513 | cout << "Enter borrowing date(Y/M/D): "; cin >> borrowdate; 514 | for (int i = MyCurrent2->BorrowNo; i < MyCurrent2->BorrowNo+1; i++){ 515 | MyCurrent2->BorrowingBook[i][0] = bkid; 516 | MyCurrent2->BorrowingBook[i][1] = Booktitle; 517 | MyCurrent2->BorrowingBook[i][2] = bcateg; 518 | MyCurrent2->BorrowingBook[i][3] = bgenre; 519 | MyCurrent2->BorrowingBook[i][4] = borrowdate;} 520 | MyCurrent2->BorrowNo += 1; 521 | cout << "The Borrowing Details" << endl; 522 | cout << " User ID : " << MyCurrent2->UID << endl; 523 | cout << " User Name : " << MyCurrent2->UName << endl; 524 | cout << " Book ID : " << MyCurrent2->BorrowingBook[MyCurrent2->BorrowNo-1][0] << endl; 525 | cout << " Book title : " << MyCurrent2->BorrowingBook[MyCurrent2->BorrowNo - 1][1] << endl; 526 | cout << " Book category : " << MyCurrent2->BorrowingBook[MyCurrent2->BorrowNo - 1][2] << endl; 527 | cout << " Book Genre : " << MyCurrent2->BorrowingBook[MyCurrent2->BorrowNo - 1][3] << endl; 528 | cout << " Borrow Date : " << MyCurrent2->BorrowingBook[MyCurrent2->BorrowNo - 1][4] << endl; 529 | cout << "|-------------------------------------------------------------------------|" << endl; 530 | break; 531 | } 532 | else 533 | MyCurrent2 = MyCurrent2->Next; 534 | } 535 | } 536 | void borrowBook(string biD,BookRecord* Head2) { 537 | BookRecord* MyCurrent1 = Head2; 538 | while (MyCurrent1 != NULL) { 539 | if (MyCurrent1->bID == biD && MyCurrent1->availability == true) { 540 | bkid= MyCurrent1->bID; 541 | Booktitle = MyCurrent1->btitle; 542 | bcateg = MyCurrent1->category; 543 | bgenre = MyCurrent1->genre; 544 | cout << "Enter User ID: "; cin >> UID; 545 | if (searchU(UID, Head) == false) 546 | { 547 | cout << "\nThis UID is not avaiable yet. Pls try again with new ID\n" << endl; 548 | break;} 549 | else { 550 | borrowbooku(UID,Head); 551 | MyCurrent1->availability = false; 552 | break; 553 | } 554 | } 555 | else 556 | MyCurrent1 = MyCurrent1->Next2; 557 | } 558 | } 559 | 560 | /*return the book*/ 561 | void returnbook() { 562 | UserRecord* MyCurrent1 = Head; 563 | string Userid,bid; 564 | cout << "\nEnter User ID: "; cin >> Userid; 565 | cout << "\nEnter Book ID to return it: "; cin >> bid; 566 | if (MyCurrent1 == NULL) { 567 | cout << "NO recode yet!!, please insert new recodes first..." << endl;} 568 | while (MyCurrent1 != NULL) { 569 | if (Userid == MyCurrent1->UID) { 570 | for (int i = 0; i < MyCurrent1->BorrowNo; i++){ 571 | if (MyCurrent1->BorrowingBook[i][0] == bid) { 572 | for (int ii = MyCurrent1->ReturnNo; ii < MyCurrent1->ReturnNo+1; ii++) 573 | { 574 | MyCurrent1->ReturningBook[ii][0] = MyCurrent1->BorrowingBook[ii][0]; 575 | MyCurrent1->ReturningBook[ii][1] = MyCurrent1->BorrowingBook[ii][1]; 576 | MyCurrent1->ReturningBook[ii][2] = MyCurrent1->BorrowingBook[ii][2]; 577 | MyCurrent1->ReturningBook[ii][3] = MyCurrent1->BorrowingBook[ii][3]; 578 | MyCurrent1->ReturningBook[ii][4] = MyCurrent1->BorrowingBook[ii][4];} 579 | 580 | BookRecord* reader = Head2; 581 | while (reader != NULL){ 582 | if (reader->bID == bid) { 583 | reader->availability = true; 584 | break;} 585 | reader = reader->Next2;} 586 | 587 | int a, j, k; 588 | int NoColumn = 5; 589 | int NORows = 3; 590 | for (a = 0; a < NORows; a++) { 591 | for (k = a; k < NORows - 1; k++) { 592 | for (j = 0; j < NoColumn; j++) { 593 | MyCurrent1->BorrowingBook[k][j] = MyCurrent1->BorrowingBook[k + 1][j];} 594 | } 595 | a--; 596 | NORows--; 597 | } 598 | } 599 | } 600 | MyCurrent1->ReturnNo += 1; 601 | MyCurrent1->BorrowNo -= 1; 602 | cout << "\n The book has been returned successfully \n"; 603 | break; 604 | } 605 | else 606 | { 607 | MyCurrent1 = MyCurrent1->Next;// go to next 608 | } 609 | } 610 | } 611 | /*function to store the book details such as id, title, categorey, genre, avaiability*/ 612 | void AddBook(){ 613 | cout << "\nPlease fill up the following requirements: \n" << endl; 614 | cout << "\n\nEnter Book ID: "; cin >> bIDInput; 615 | if (Searchb(bIDInput, Head2) == true) { 616 | cout << "\n This ID has been used before !!\n" << endl;} 617 | else { 618 | getchar(); 619 | cout << "Enter Book Title: "; getline(cin, btitleInput, '\n'); 620 | cout << "Enter Book Category(1. Fiction 2. Non-Fiction): "; cin >> option1; 621 | if (option1 == '1') { 622 | categoryInput = category1; 623 | cout << "Enter Book genre: "; 624 | cout << "1. Drama 2. Romance 3. Historical 4. Realistic 5. Fan\nEnter one option: "; 625 | cin >> option2; 626 | if (option2 == '1') { 627 | genreInput = genre1; 628 | } 629 | else if (option2 == '2') { 630 | genreInput = genre2; 631 | } 632 | else if (option2 == '3') { 633 | genreInput = genre3; 634 | } 635 | else if (option2 == '4') { 636 | genreInput = genre4; 637 | } 638 | else { 639 | genreInput = genre5; 640 | } 641 | } 642 | else { 643 | categoryInput = category2; 644 | cout << "Enter Book genre: "; 645 | cout << "1. Drama 2. Romance 3. Historical 4. Realistic 5. Fan\nEnter one option: "; 646 | cin >> option2; 647 | if (option2 == '1') { 648 | genreInput = genre6; 649 | } 650 | else if (option2 == '2') { 651 | genreInput = genre7; 652 | } 653 | else if (option2 == '3') { 654 | genreInput = genre8; 655 | } 656 | else if (option2 == '4') { 657 | genreInput = genre9; 658 | } 659 | else { 660 | genreInput = genre10; 661 | } 662 | } 663 | availabilityInput = true; 664 | cout << "Enter the position you want to save the recode: "; cin >> position; 665 | linkedlistb(bIDInput, btitleInput, categoryInput, genreInput, availabilityInput, position); 666 | place2++; 667 | } 668 | return; 669 | } 670 | 671 | /*add User account*/ 672 | void AddUser() 673 | { 674 | cout << "\nPlease fill up the following requirements: \n" << endl; 675 | cout << "Enter User ID: "; cin >> UIDInput; 676 | if (searchU(UIDInput, Head) == true) { 677 | cout << "\n This ID has been used before !!\n" << endl; 678 | } 679 | else 680 | { 681 | getchar(); 682 | cout << "Enter User Name: "; getline(cin, UNameInput, '\n'); 683 | cout << "Enter Phone No: "; getline(cin, PhoneInput, '\n'); 684 | cout << "Enter the position you want to save the recode: "; cin >> position; 685 | linkedlistU(UIDInput, UNameInput, PhoneInput, position); 686 | place++; 687 | } 688 | return; 689 | } 690 | 691 | /*SignIn page*/ 692 | void SignIn() { 693 | system("color 2"); 694 | string pin; 695 | system("cls"); 696 | cout << "\n <=======> Library Management System (LMS) <=======>\n"; 697 | cout << "\n <=======> By- Krishnika Gupta <=======>\n"; 698 | cout << "\nEnter your PIN to access :: "; cin >> pin; 699 | if (pin == "krishna@123") { 700 | cout << "\n <> Correct PIN <> \n"; 701 | system("pause"); 702 | system("cls"); 703 | } 704 | else { 705 | cout << "\n <> Wrong PIN <>\n"; 706 | SignIn(); 707 | } 708 | } 709 | 710 | /*the main function of the system */ 711 | int main() { 712 | string sbtitle; 713 | string bookid, borrowid; 714 | SignIn(); 715 | system("color 4");/*changing the color to red*/ 716 | 717 | do{ 718 | cout<< "\n\n <=======> Library Management System <=======>\n"; 719 | cout << "\n\n <=======> By Krishnika Gupta <=======>\n"; 720 | cout<<"\n\n 1. Book Services 2. User Services 3. Exit"<> choice; 722 | switch (choice){ 723 | case '1': 724 | do{ 725 | cout << "\n\n <=======> User Service <=======>\n"; 726 | cout<< " \n\n1. Add New Book 2. Display Books 3. Search Book\n\n 4. Update Book Information 5. Back" << endl; 727 | cout << "\n\nEnter one choice: "; cin >> choice; 728 | switch (choice) 729 | { 730 | case '1': 731 | AddBook(); 732 | break; 733 | case '2': 734 | cout << "\n1. Display all books. 2. Display the avaiable books only. \nEnter one option: "; cin >> choice; 735 | if (choice == '1') { 736 | DisplayBook(Head2); 737 | } 738 | else { 739 | DisplayBookA(Head2); 740 | } 741 | cout << "\nDo you want to borrow any book: (1. Yes 2. NO): "; cin >> choice; 742 | if (choice == '1') { 743 | 744 | cout << "Enter Book ID: "; cin >> borrowid; 745 | borrowBook(borrowid, Head2); 746 | } 747 | else { 748 | cout << "\n Backing to the main menu....\n" << endl; 749 | } 750 | break; 751 | case '3': 752 | getchar(); 753 | cout << "\nEnter the book title or category or genre to search: "; getline(cin, sbtitle, '\n'); 754 | SearchBook(sbtitle, Head2); 755 | cout << "\nDo you want to borrow any book: (1. Yes 2. NO): "; cin>> choice; 756 | if (choice == '1') { 757 | 758 | cout << "Enter Book ID: "; cin >> borrowid; 759 | borrowBook(borrowid, Head2); 760 | } 761 | else { 762 | cout << "\n Backing to the main menu....\n" << endl; 763 | } 764 | break; 765 | case '4': 766 | cout << "\nEnter Book ID to update: "; cin >> bookid; 767 | UpdateBook(bookid, Head2); 768 | break; 769 | case '5': 770 | cout << "\n Backing to the main menu....\n" << endl; 771 | break; 772 | default: 773 | cerr << "\n\n Wrong Choice " << endl; 774 | break; 775 | } 776 | system("pause"); 777 | system("cls"); 778 | } while (choice != '5'); 779 | break; 780 | case '2': 781 | do 782 | { 783 | cerr << "\n\n <=======> Users Service <=======>\n" 784 | " 1. Add New User 2. Display the last 10 books borrowed by a User\n" 785 | " 3. Search User 4. Update User Info 5. Return a Borrowed book\n" 786 | " 6. View all Users with active book borrowed. 7. Back" << endl; 787 | cout << "Enter one choice: "; cin >> choice; 788 | switch (choice) 789 | { 790 | case '1': 791 | AddUser(); 792 | break; 793 | case '2': 794 | UlastborrowedB(Head); 795 | break; 796 | case '3': 797 | searchURecord(Head); 798 | break; 799 | case '4': 800 | UpdateUInfo(); 801 | break; 802 | case '5': 803 | returnbook(); 804 | break; 805 | case '6': 806 | DisplayUsers(Head); 807 | break; 808 | case '7': 809 | cout << "\n Backing to the main menu....\n" << endl; 810 | break; 811 | default: 812 | cerr << " Wrong Choice " << endl; 813 | break; 814 | } 815 | system("pause"); 816 | system("cls"); 817 | } while (choice != '7'); 818 | break; 819 | case '3': 820 | cout <<"\n <***> See You Soon ! :) <***>\n"< Wrong Choice "< 2 | const char ROCK = 'r'; 3 | const char PAPER = 'p'; 4 | const char SCISSORS = 's'; 5 | using namespace std; 6 | char getComputerOption() { 7 | srand(time(0)); 8 | int num = rand() % 3 + 1; 9 | if(num==1) return 'r'; 10 | if(num==2) return 'p'; 11 | if(num==3) return 's'; 12 | } 13 | char getUserOption() { 14 | char c; 15 | cout << "Rock, Paper and Scissors Game!" << endl; 16 | cout << "Choose one of the following options" << endl; 17 | cout << "-----------------------------------" << endl; 18 | cout << "(r) for rock " << endl << "(p) for paper" << endl << "(s) for scissors " << endl; 19 | cin >> c; 20 | while (c!='r' && c!='p' && c!='s' ) 21 | { 22 | cout << "Please enter one of the following options only. " << endl; 23 | cout << "(r) for rock " << endl << "(p) for paper" << endl << "(s) for scissors " << endl; 24 | cin >> c; 25 | } 26 | return c; 27 | } 28 | void showSelectedOption(char option) { 29 | if (option == 'r') cout << "Rock" << endl; 30 | if (option == 'p') cout << "Paper" << endl; 31 | if (option == 's') cout << "Scissors" << endl; 32 | } 33 | void chooseWinner(char uChoice, char cChoice) { 34 | if (uChoice == ROCK && cChoice == PAPER) { 35 | cout << "Computer Wins! Paper wraps Rock."<< endl; 36 | } 37 | else if (uChoice == PAPER && cChoice == SCISSORS) { 38 | cout << "Computer Wins! Scissors cut Paper."<< endl; 39 | 40 | } 41 | else if (uChoice == SCISSORS && cChoice == ROCK) { 42 | cout << "Computer Wins! Rock smashes Scissors."<< endl; 43 | 44 | } 45 | else if (uChoice == ROCK && cChoice == SCISSORS) { 46 | cout << "You Win! Paper wraps Rock."<< endl; 47 | 48 | } 49 | else if (uChoice == PAPER && cChoice == ROCK) { 50 | cout << "You Win! Paper wraps Rock."<< endl; 51 | 52 | } 53 | else if (uChoice == SCISSORS && cChoice == PAPER) { 54 | cout << "You Win! Scissors cut Paper."<< endl; 55 | } 56 | else{ 57 | cout << "Tie. Play again win the Game." << endl; 58 | } 59 | } 60 | 61 | int main() { 62 | char uChoice; 63 | char cChoice; 64 | uChoice = getUserOption(); 65 | cout << "Your choice is: "<< endl; 66 | showSelectedOption(uChoice); 67 | cout << "Computer's choice is: "<< endl; 68 | cChoice = getComputerOption(); 69 | showSelectedOption(cChoice); 70 | chooseWinner(uChoice, cChoice); 71 | return 0; 72 | } 73 | -------------------------------------------------------------------------------- /Projects/Score Keeping Game/ScoreKeeping_Game: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Projects/Score Keeping Game/app.js: -------------------------------------------------------------------------------- 1 | const p1Button = document.querySelector('#p1Button'); 2 | const p2Button = document.querySelector('#p2Button'); 3 | const resetButton = document.querySelector('#reset'); 4 | const p1Display = document.querySelector('#p1Display'); 5 | const p2Display = document.querySelector('#p2Display'); 6 | const winningScoreSelect = document.querySelector('#playto'); 7 | 8 | let p1Score = 0; 9 | let p2Score = 0; 10 | let winningScore = 5; 11 | let isGameOver = false; 12 | 13 | p1Button.addEventListener('click', function () { 14 | if (!isGameOver) { 15 | p1Score++; 16 | if (p1Score === winningScore) { 17 | isGameOver = true; 18 | p1Display.classList.remove('has-text-success', 'has-text-danger'); 19 | p2Display.classList.remove('has-text-success', 'has-text-danger'); 20 | } 21 | p1Display.textContent = p1Score; 22 | } 23 | }) 24 | 25 | p2Button.addEventListener('click', function () { 26 | if (!isGameOver) { 27 | p2Score++; 28 | if (p2Score === winningScore) { 29 | isGameOver = true; 30 | p2Display.classList.add('has-text-success'); 31 | p1Display.classList.add('has-text-danger'); 32 | p1Button.disabled = true; 33 | p2Button.disabled = true; 34 | } 35 | p2Display.textContent = p2Score; 36 | } 37 | }) 38 | 39 | winningScoreSelect.addEventListener('change', function () { 40 | winningScore = parseInt(this.value); 41 | reset(); 42 | }) 43 | 44 | resetButton.addEventListener('click', reset) 45 | 46 | function reset() { 47 | isGameOver = false; 48 | p1Score = 0; 49 | p2Score = 0; 50 | p1Display.textContent = 0; 51 | p2Display.textContent = 0; 52 | p1Display.classList.remove('has-text-success', 'has-text-danger'); 53 | p2Display.classList.remove('has-text-success', 'has-text-danger'); 54 | p1Button.disabled = false; 55 | p2Button.disabled = false; 56 | } -------------------------------------------------------------------------------- /Projects/Score Keeping Game/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Score Keeper 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | 23 |
24 |
25 |
26 |

27 | Ping Pong Score Keeper 28 |

29 | 34 |
35 |
36 |
37 |

0 to 0 38 |

39 |

Use the buttons below to keep score.

40 | 41 |
42 | 53 |
54 |
55 |
56 |
57 | 58 | 59 | 60 |
61 |
62 |
63 |
64 |
65 | 66 |
67 | 68 | 69 | -------------------------------------------------------------------------------- /Projects/Student Grading System/README.md: -------------------------------------------------------------------------------- 1 | # HacktoberFest2022 2 | About Submit Just 4 PRs to earn SWAGS and Tshirts🔥 3 | 4 | 5 | # 🌱 Contributing to hacktoberfest 2022 6 | 7 | ![Hacktoberfest 2022](https://github.com/RajkumarSony/HacktoberFest2022/blob/main/logo.png) 8 | 9 | --- 10 | 11 | ### Welcome to hacktoberfest 2022 Public Repository. 👨🏻‍💻 12 | 13 | 🗣 **A month-long celebration from September 26 to October 31 sponsored by Digital Ocean and GitHub to get people involved in Open Source. Create your very first pull request to any public repository on GitHub and contribute to the open source developer community.** 14 | 15 | 📢 **Register [here](https://hacktoberfest.digitalocean.com/) for Hacktoberfest and make four pull requests (PRs) and Complete the challenge between from September 26 and October 31 to grab free SWAGS and earn a limited edition T-shirt 🔥.** 16 | 17 | --- 18 | 19 | ## Rules 20 | 21 | - Don't use filthy words and be welcome for beginners and other people in this community. 22 | 23 | --- 24 | 25 | ## Github Contribution Rules 26 | - Pull requests can be submitted to any opted-in repository on GitHub or GitLab. 27 | - The pull request must contain commits you made yourself. 28 | - If a maintainer reports your pull request as spam, it will not be counted toward your participation in Hacktoberfest. 29 | - If a maintainer reports behavior that’s not in line with the project’s code of conduct, you will be ineligible to participate. 30 | - To get a shirt, you must make 4 approved pull/merge requests on opted-in projects between September 26 and October 31 in any time zone. 31 | - This year, the first 40,000 participants can earn a T-shirt. 32 | 33 | --- 34 | 35 | ### What can You contribute ⚠️ 36 | 37 | - There are language Specific folders in the repository choose any you're comfortable with if not, make one. 38 | - Inside the Projects folder, Upload the unique projects with proper project title. 39 | - Contribute your small or mini projects, that can be in different languages. 40 | - Make sure your follow the below steps. 41 | 42 | --- 43 | 44 | ### Process are as follows :- 45 | 46 | - Login using github @ [Hacktoberfest](https://hacktoberfest.digitalocean.com/) 47 | - Create four valid pull requests (PRs) between September 26 and October 31. 48 | 49 | - Follow the Hacktoberfest Maintainer here @ [LinkedIn](https://linkedin.com/in/RajkumarSony/), @ [Github](https://github.com/RajkumarSony), @ [Instagram](https://www.instagram.com/rajkumarsony_/) 50 | 51 | 52 | 53 |
54 | Raj Kumar Sony

55 | 56 | 57 | 58 | --- 59 | 60 | ### How to Contribute to this repository 61 | 62 | - Fork the repository (Click the Fork button in the top right of this page, click your Profile Image) 63 | - Clone the forked repository to your local machine. 64 | 65 | ```markdown 66 | git clone https://github.com/RajkumarSony/HacktoberFest2022.git 67 | ``` 68 | 69 | - Change the present working directory. 70 | 71 | ```markdown 72 | cd HacktoberFest2022 73 | ``` 74 | 75 | - Add/Create your project to the specific folder as described in what you can contribute section. 76 | - Make a new branch. 77 | 78 | ```markdown 79 | git checkout -b branch-name 80 | ``` 81 | 82 | - Make change in the repository with the new branch. 83 | - push the changes. 84 | 85 | ```markdown 86 | git add . 87 | git commit -m "Your commit Message" 88 | git push origin branch-name 89 | ``` 90 | 91 | - Make a pull request. 92 | - Star the repository. 93 | 94 | ### NOTE 95 | 96 | - Make Sure you commit your changes in a new branch. 97 | - Make Sure you Give proper name to your files describing the addition. 98 | - Also Make Sure you comment your code whereever necessary. 99 | 100 | 101 | 102 | 103 |
104 | Raj Kumar Sony

105 | 106 | 107 | 108 | 109 | -------------------------------------------------------------------------------- /Projects/Student Grading System/Student Grading System.py: -------------------------------------------------------------------------------- 1 | print("Enter Marks Obtained in 5 Subjects: ") 2 | markOne = int(input()) 3 | markTwo = int(input()) 4 | markThree = int(input()) 5 | markFour = int(input()) 6 | markFive = int(input()) 7 | 8 | tot = markOne+markTwo+markThree+markFour+markFive 9 | avg = tot/5 10 | 11 | if avg>=91 and avg<=100: 12 | print("Your Grade is A1") 13 | elif avg>=81 and avg<91: 14 | print("Your Grade is A2") 15 | elif avg>=71 and avg<81: 16 | print("Your Grade is B1") 17 | elif avg>=61 and avg<71: 18 | print("Your Grade is B2") 19 | elif avg>=51 and avg<61: 20 | print("Your Grade is C1") 21 | elif avg>=41 and avg<51: 22 | print("Your Grade is C2") 23 | elif avg>=33 and avg<41: 24 | print("Your Grade is D") 25 | elif avg>=21 and avg<33: 26 | print("Your Grade is E1") 27 | elif avg>=0 and avg<21: 28 | print("Your Grade is E2") 29 | else: 30 | print("Invalid Input!") -------------------------------------------------------------------------------- /Projects/Student Grading System/calculator.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Calculator 8 | 40 | 41 | 42 |
43 |
44 |
45 |
46 |
C
47 |
%
48 |
DL
49 |
/
50 |
7
51 |
8
52 |
9
53 |
*
54 |
4
55 |
5
56 |
6
57 |
-
58 |
1
59 |
2
60 |
3
61 |
+
62 |
00
63 |
0
64 |
.
65 |
=
66 |
67 |
68 |
69 | 70 | 105 | 106 | 107 | -------------------------------------------------------------------------------- /Projects/ege catcher/egecatcher.py: -------------------------------------------------------------------------------- 1 | from itertools import cycle 2 | from random import randrange 3 | from tkinter import Canvas, Tk, messagebox, font 4 | 5 | canvas_width = 800 6 | canvas_height = 400 7 | 8 | root = Tk() 9 | c = Canvas(root, width=canvas_width, height=canvas_height, background="deep sky blue") 10 | c.create_rectangle(-5, canvas_height-100, canvas_width+5, canvas_height+5, fill="sea green", width=0) 11 | c.create_oval(-80, -80, 120, 120, fill='orange', width=0) 12 | c.pack() 13 | 14 | color_cycle = cycle(["light blue", "light green", "light pink", "light yellow", "light cyan"]) 15 | egg_width = 45 16 | egg_height = 55 17 | egg_score = 10 18 | egg_speed = 500 19 | egg_interval = 4000 20 | difficulty = 0.95 21 | catcher_color = "blue" 22 | catcher_width = 100 23 | catcher_height = 100 24 | catcher_startx = canvas_width / 2 - catcher_width / 2 25 | catcher_starty = canvas_height - catcher_height - 20 26 | catcher_startx2 = catcher_startx + catcher_width 27 | catcher_starty2 = catcher_starty + catcher_height 28 | 29 | catcher = c.create_arc(catcher_startx, catcher_starty, catcher_startx2, catcher_starty2, start=200, extent=140, style="arc", outline=catcher_color, width=3) 30 | game_font = font.nametofont("TkFixedFont") 31 | game_font.config(size=18) 32 | 33 | 34 | score = 0 35 | score_text = c.create_text(10, 10, anchor="nw", font=game_font, fill="darkblue", text="Score: "+ str(score)) 36 | 37 | lives_remaining = 3 38 | lives_text = c.create_text(canvas_width-10, 10, anchor="ne", font=game_font, fill="darkblue", text="Lives: "+ str(lives_remaining)) 39 | 40 | eggs = [] 41 | 42 | def create_egg(): 43 | x = randrange(10, 740) 44 | y = 40 45 | new_egg = c.create_oval(x, y, x+egg_width, y+egg_height, fill=next(color_cycle), width=0) 46 | eggs.append(new_egg) 47 | root.after(egg_interval, create_egg) 48 | 49 | def move_eggs(): 50 | for egg in eggs: 51 | (eggx, eggy, eggx2, eggy2) = c.coords(egg) 52 | c.move(egg, 0, 10) 53 | if eggy2 > canvas_height: 54 | egg_dropped(egg) 55 | root.after(egg_speed, move_eggs) 56 | 57 | def egg_dropped(egg): 58 | eggs.remove(egg) 59 | c.delete(egg) 60 | lose_a_life() 61 | if lives_remaining == 0: 62 | messagebox.showinfo("Game Over!", "Final Score: "+ str(score)) 63 | root.destroy() 64 | 65 | def lose_a_life(): 66 | global lives_remaining 67 | lives_remaining -= 1 68 | c.itemconfigure(lives_text, text="Lives: "+ str(lives_remaining)) 69 | 70 | def check_catch(): 71 | (catcherx, catchery, catcherx2, catchery2) = c.coords(catcher) 72 | for egg in eggs: 73 | (eggx, eggy, eggx2, eggy2) = c.coords(egg) 74 | if catcherx < eggx and eggx2 < catcherx2 and catchery2 - eggy2 < 40: 75 | eggs.remove(egg) 76 | c.delete(egg) 77 | increase_score(egg_score) 78 | root.after(100, check_catch) 79 | 80 | def increase_score(points): 81 | global score, egg_speed, egg_interval 82 | score += points 83 | egg_speed = int(egg_speed * difficulty) 84 | egg_interval = int(egg_interval * difficulty) 85 | c.itemconfigure(score_text, text="Score: "+ str(score)) 86 | 87 | def move_left(event): 88 | (x1, y1, x2, y2) = c.coords(catcher) 89 | if x1 > 0: 90 | c.move(catcher, -20, 0) 91 | 92 | def move_right(event): 93 | (x1, y1, x2, y2) = c.coords(catcher) 94 | if x2 < canvas_width: 95 | c.move(catcher, 20, 0) 96 | 97 | c.bind("", move_left) 98 | c.bind("", move_right) 99 | c.focus_set() 100 | root.after(1000, create_egg) 101 | root.after(1000, move_eggs) 102 | root.after(1000, check_catch) 103 | root.mainloop() -------------------------------------------------------------------------------- /Projects/helmet.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import numpy as np 3 | import random 4 | import os 5 | from PIL import Image 6 | import time 7 | import imutils 8 | from tensorflow.keras.models import load_model 9 | 10 | os.environ['TF_FORCE_GPU_ALLOW_GROWTH'] = 'true' 11 | 12 | net = cv2.dnn.readNet("yolov3-custom_7000.weights", "yolov3-custom.cfg") 13 | net.setPreferableBackend(cv2.dnn.DNN_BACKEND_CUDA) 14 | net.setPreferableTarget(cv2.dnn.DNN_TARGET_CUDA) 15 | 16 | 17 | model = load_model('helmet-nonhelmet_cnn.h5') 18 | print('model loaded!!!') 19 | 20 | cap = cv2.VideoCapture('testing videos/test2.mp4') 21 | COLORS = [(0,255,0),(0,0,255)] 22 | 23 | fourcc = cv2.VideoWriter_fourcc(*"XVID") 24 | writer = cv2.VideoWriter('output.avi', fourcc, 5,(888,500)) 25 | writer = VideoWriter('output.avi',(frame.shape[1], frame.shape[0])) 26 | writer.open() 27 | 28 | 29 | def helmet_or_nohelmet(helmet_roi): 30 | try: 31 | helmet_roi = cv2.resize(helmet_roi, (224, 224)) 32 | helmet_roi = np.array(helmet_roi,dtype='float32') 33 | helmet_roi = helmet_roi.reshape(1, 224, 224, 3) 34 | helmet_roi = helmet_roi/255.0 35 | return int(model.predict(helmet_roi)[0][0]) 36 | except: 37 | pass 38 | 39 | layer_names = net.getLayerNames() 40 | output_layers = [layer_names[i[0] - 1] for i in net.getUnconnectedOutLayers()] 41 | 42 | ret = True 43 | 44 | while ret: 45 | 46 | ret, img = cap.read() 47 | img = imutils.resize(img,height=500) 48 | # img = cv2.imread('test.png') 49 | height, width = img.shape[:2] 50 | 51 | blob = cv2.dnn.blobFromImage(img, 0.00392, (416, 416), (0, 0, 0), True, crop=False) 52 | 53 | net.setInput(blob) 54 | outs = net.forward(output_layers) 55 | 56 | confidences = [] 57 | boxes = [] 58 | classIds = [] 59 | 60 | for out in outs: 61 | for detection in out: 62 | scores = detection[5:] 63 | class_id = np.argmax(scores) 64 | confidence = scores[class_id] 65 | if confidence > 0.3: 66 | center_x = int(detection[0] * width) 67 | center_y = int(detection[1] * height) 68 | 69 | w = int(detection[2] * width) 70 | h = int(detection[3] * height) 71 | x = int(center_x - w / 2) 72 | y = int(center_y - h / 2) 73 | 74 | boxes.append([x, y, w, h]) 75 | confidences.append(float(confidence)) 76 | classIds.append(class_id) 77 | 78 | indexes = cv2.dnn.NMSBoxes(boxes, confidences, 0.5, 0.4) 79 | 80 | for i in range(len(boxes)): 81 | if i in indexes: 82 | x,y,w,h = boxes[i] 83 | color = [int(c) for c in COLORS[classIds[i]]] 84 | # green --> bike 85 | # red --> number plate 86 | if classIds[i]==0: #bike 87 | helmet_roi = img[max(0,y):max(0,y)+max(0,h)//4,max(0,x):max(0,x)+max(0,w)] 88 | else: #number plate 89 | x_h = x-60 90 | y_h = y-350 91 | w_h = w+100 92 | h_h = h+100 93 | cv2.rectangle(img, (x, y), (x + w, y + h), color, 7) 94 | # h_r = img[max(0,(y-330)):max(0,(y-330 + h+100)) , max(0,(x-80)):max(0,(x-80 + w+130))] 95 | if y_h>0 and x_h>0: 96 | h_r = img[y_h:y_h+h_h , x_h:x_h +w_h] 97 | c = helmet_or_nohelmet(h_r) 98 | cv2.putText(img,['helmet','no-helmet'][c],(x,y-100),cv2.FONT_HERSHEY_SIMPLEX,2,(0,255,0),2) 99 | cv2.rectangle(img, (x_h, y_h), (x_h + w_h, y_h + h_h),(255,0,0), 10) 100 | 101 | 102 | writer.write(img) 103 | cv2.imshow("Image", img) 104 | 105 | if cv2.waitKey(1) == 27: 106 | break 107 | 108 | writer.release() 109 | cap.release() 110 | cv2.waitKey(0) 111 | cv2.destroyAllWindows() -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Best of Luck!! 4 | 5 | --- 6 | 7 | ## HacktoberFest2022 8 | About Submit Just 4 PRs to earn SWAGS and Tshirts🔥 9 | 10 | 11 | ## 🌱 Contributing to hacktoberfest 2022 12 | 13 | ![Hacktoberfest 2022](https://github.com/RajkumarSony/HacktoberFest2022/blob/main/logo.png) 14 | 15 | --- 16 | 17 | ### Welcome to hacktoberfest 2022 Public Repository. 👨🏻‍💻 18 | 19 | 🗣 **A month-long celebration from September 26 to October 31 sponsored by Digital Ocean and GitHub to get people involved in Open Source. Create your very first pull request to any public repository on GitHub and contribute to the open source developer community.** 20 | 21 | 📢 **Register [here](https://hacktoberfest.digitalocean.com/) for Hacktoberfest and make four pull requests (PRs) and Complete the challenge between from September 26 and October 31 to grab free SWAGS and earn a limited edition T-shirt 🔥.** 22 | 23 | --- 24 | 25 | ## Rules 26 | 27 | - Don't use filthy words and be welcome for beginners and other people in this community. 28 | 29 | --- 30 | 31 | ## Github Contribution Rules 32 | - Pull requests can be submitted to any opted-in repository on GitHub or GitLab. 33 | - The pull request must contain commits you made yourself. 34 | - If a maintainer reports your pull request as spam, it will not be counted toward your participation in Hacktoberfest. 35 | - If a maintainer reports behavior that’s not in line with the project’s code of conduct, you will be ineligible to participate. 36 | - To get a shirt, you must make 4 approved pull/merge requests on opted-in projects between September 26 and October 31 in any time zone. 37 | - This year, the first 40,000 participants can earn a T-shirt. 38 | 39 | --- 40 | 41 | ### What can You contribute ⚠️ 42 | 43 | - There are language Specific folders in the repository choose any you're comfortable with if not, make one. 44 | - Inside the Projects folder, Upload the unique projects with proper project title. 45 | - Contribute your small or mini projects, that can be in different languages. 46 | - Make sure your follow the below steps. 47 | 48 | --- 49 | 50 | ### Process are as follows :- 51 | 52 | - Login using github @ [Hacktoberfest](https://hacktoberfest.digitalocean.com/) 53 | - Create four valid pull requests (PRs) between September 26 and October 31. 54 | 55 | - Follow the Hacktoberfest Maintainer here @ [LinkedIn](https://linkedin.com/in/RajkumarSony/), @ [Github](https://github.com/RajkumarSony), @ [Instagram](https://www.instagram.com/rajkumarsony_/) 56 | 57 | 58 | 59 |
60 | Raj Kumar Sony

61 | 62 | 63 | 64 | --- 65 | 66 | ### How to Contribute to this repository 67 | 68 | - Fork the repository (Click the Fork button in the top right of this page, click your Profile Image) 69 | - Clone the forked repository to your local machine. 70 | 71 | ```markdown 72 | git clone https://github.com/RajkumarSony/HacktoberFest2022.git 73 | ``` 74 | 75 | - Change the present working directory. 76 | 77 | ```markdown 78 | cd HacktoberFest2022 79 | ``` 80 | 81 | - Add/Create your project to the specific folder as described in what you can contribute section. 82 | - Make a new branch. 83 | 84 | ```markdown 85 | git checkout -b branch-name 86 | ``` 87 | 88 | - Make change in the repository with the new branch. 89 | - push the changes. 90 | 91 | ```markdown 92 | git add . 93 | git commit -m "Your commit Message" 94 | git push origin branch-name 95 | ``` 96 | 97 | - Make a pull request. 98 | - Star the repository. 99 | 100 | ### NOTE 101 | 102 | - Make Sure you commit your changes in a new branch. 103 | - Make Sure you Give proper name to your files describing the addition. 104 | - Also Make Sure you comment your code whereever necessary. 105 | 106 | 107 | 108 | 109 |
110 | Raj Kumar Sony

111 | 112 | 113 | 114 | 115 | -------------------------------------------------------------------------------- /Remove duplicates from a sorted linked list.cpp: -------------------------------------------------------------------------------- 1 | /* C++ Program to remove duplicates from a sorted linked list */ 2 | #include 3 | using namespace std; 4 | 5 | /* Link list node */ 6 | class Node 7 | { 8 | public: 9 | int data; 10 | Node* next; 11 | }; 12 | 13 | /* The function removes duplicates from a sorted list */ 14 | void removeDuplicates(Node* head) 15 | { 16 | /* Pointer to traverse the linked list */ 17 | Node* current = head; 18 | 19 | /* Pointer to store the next pointer of a node to be deleted*/ 20 | Node* next_next; 21 | 22 | /* do nothing if the list is empty */ 23 | if (current == NULL) 24 | return; 25 | 26 | /* Traverse the list till last node */ 27 | while (current->next != NULL) 28 | { 29 | /* Compare current node with next node */ 30 | if (current->data == current->next->data) 31 | { 32 | /* The sequence of steps is important*/ 33 | next_next = current->next->next; 34 | free(current->next); 35 | current->next = next_next; 36 | } 37 | else /* This is tricky: only advance if no deletion */ 38 | { 39 | current = current->next; 40 | } 41 | } 42 | } 43 | 44 | /* UTILITY FUNCTIONS */ 45 | /* Function to insert a node at the beginning of the linked list */ 46 | void push(Node** head_ref, int new_data) 47 | { 48 | /* allocate node */ 49 | Node* new_node = new Node(); 50 | 51 | /* put in the data */ 52 | new_node->data = new_data; 53 | 54 | /* link the old list off the new node */ 55 | new_node->next = (*head_ref); 56 | 57 | /* move the head to point to the new node */ 58 | (*head_ref) = new_node; 59 | } 60 | 61 | /* Function to print nodes in a given linked list */ 62 | void printList(Node *node) 63 | { 64 | while (node!=NULL) 65 | { 66 | cout<<" "<data; 67 | node = node->next; 68 | } 69 | } 70 | 71 | /* Driver program to test above functions*/ 72 | int main() 73 | { 74 | /* Start with the empty list */ 75 | Node* head = NULL; 76 | 77 | /* Let us create a sorted linked list to test the functions 78 | Created linked list will be 11->11->11->13->13->20 */ 79 | push(&head, 20); 80 | push(&head, 13); 81 | push(&head, 13); 82 | push(&head, 11); 83 | push(&head, 11); 84 | push(&head, 11); 85 | 86 | cout<<"Linked list before duplicate removal "; 87 | printList(head); 88 | 89 | /* Remove duplicates from linked list */ 90 | removeDuplicates(head); 91 | 92 | cout<<"\nLinked list after duplicate removal "; 93 | printList(head); 94 | 95 | return 0; 96 | } 97 | -------------------------------------------------------------------------------- /Subway Ride.java/Subway Ride.java: -------------------------------------------------------------------------------- 1 | /*input 2 | 3 3 3 | 1 7 4 | 10 5 5 | 8 9 6 | 3 0 7 | 3 1 1 8 | 6 2 1 2 9 | 10 | */ 11 | import java.io.ByteArrayInputStream; 12 | import java.io.IOException; 13 | import java.io.InputStream; 14 | import java.io.PrintWriter; 15 | import java.util.*; 16 | //Exponential Learning or Nothing 17 | public class Main { 18 | 19 | InputStream is; 20 | PrintWriter out; 21 | String INPUT = ""; 22 | //class Declaration 23 | static int n,m; 24 | static ArrayList>> tp; 25 | static int end=0,start=0,ans=0; 26 | 27 | static class pii implements Comparable{ 28 | int x,y; 29 | pii (int i,int j) 30 | { x=i; y=j;} 31 | public int compareTo(pii p){ 32 | if(this.x!=p.x) { return this.x-p.x;} 33 | else { return this.y-p.y;} 34 | } 35 | public int hashCode() { return (x+" "+y).hashCode();} 36 | public String toString(){ return x+" "+y;} 37 | public boolean equals(pii x){ return (x.x==this.x&&x.y==this.y);} 38 | } 39 | int[][] dp; 40 | void solve(){ 41 | n=ni();m=ni(); 42 | 43 | tp=new ArrayList<>(); 44 | 45 | 46 | 47 | 48 | for(int i=0;i >()); 50 | } 51 | for(int i=0;i> hm=tp.get(u); 55 | HashMap> hm2=tp.get(v); 56 | 57 | 58 | 59 | if(!hm.containsKey(v)){ 60 | HashSet hs=new HashSet<>(); 61 | hs.add(w); 62 | hm.put(v,hs); 63 | } 64 | else{ 65 | hm.get(v).add(w); 66 | } 67 | 68 | 69 | if(!hm2.containsKey(u)){ 70 | HashSet hs=new HashSet<>(); 71 | hs.add(w); 72 | hm2.put(u,hs); 73 | } 74 | else{ 75 | hm2.get(u).add(w); 76 | } 77 | 78 | } 79 | dp=new int[n][n]; 80 | for(int i=0;i> hm=tp.get(s); 114 | Set key=hm.keySet(); 115 | if(s==end){ 116 | ans=a; 117 | return; 118 | } 119 | if(s==start){ 120 | int fa=-1; 121 | for(int x:key){ 122 | HashSet colour=hm.get(x); 123 | for(int y:colour){ 124 | ans=0; 125 | traverse(x,s,y,false,a+1); 126 | 127 | fa=Math.max(fa,ans); 128 | } 129 | 130 | } 131 | ans=fa; 132 | return; 133 | } 134 | 135 | for(int x:key){ 136 | if(x==p) continue; 137 | HashSet colour=hm.get(x); 138 | int ind=0; 139 | for(int y:colour){ 140 | ind++; 141 | 142 | 143 | if(y!=pc){ 144 | if(indarr[i]) min=arr[i]; 168 | } 169 | return min; 170 | } 171 | int max(int[] arr) 172 | { 173 | int max=Integer.MIN_VALUE; 174 | for(int i=0;i= lenbuf){ 237 | ptrbuf = 0; 238 | try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); } 239 | if(lenbuf <= 0)return -1; 240 | } 241 | return inbuf[ptrbuf++]; 242 | } 243 | 244 | private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); } 245 | private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; } 246 | 247 | private double nd() { return Double.parseDouble(ns()); } 248 | private char nc() { return (char)skip(); } 249 | 250 | private String ns() 251 | { 252 | int b = skip(); 253 | StringBuilder sb = new StringBuilder(); 254 | while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ') 255 | sb.appendCodePoint(b); 256 | b = readByte(); 257 | } 258 | return sb.toString(); 259 | } 260 | 261 | private char[] ns(int n) 262 | { 263 | char[] buf = new char[n]; 264 | int b = skip(), p = 0; 265 | while(p < n && !(isSpaceChar(b))){ 266 | buf[p++] = (char)b; 267 | b = readByte(); 268 | } 269 | return n == p ? buf : Arrays.copyOf(buf, p); 270 | } 271 | 272 | private char[][] nm(int n, int m) 273 | { 274 | char[][] map = new char[n][]; 275 | for(int i = 0;i < n;i++)map[i] = ns(m); 276 | return map; 277 | } 278 | 279 | private int[] na(int n) 280 | { 281 | int[] a = new int[n]; 282 | for(int i = 0;i < n;i++)a[i] = ni(); 283 | return a; 284 | } 285 | 286 | private int ni() 287 | { 288 | int num = 0, b; 289 | boolean minus = false; 290 | while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')); 291 | if(b == '-'){ 292 | minus = true; 293 | b = readByte(); 294 | } 295 | 296 | while(true){ 297 | if(b >= '0' && b <= '9'){ 298 | num = num * 10 + (b - '0'); 299 | }else{ 300 | return minus ? -num : num; 301 | } 302 | b = readByte(); 303 | } 304 | } 305 | 306 | private long nl() 307 | { 308 | long num = 0; 309 | int b; 310 | boolean minus = false; 311 | while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')); 312 | if(b == '-'){ 313 | minus = true; 314 | b = readByte(); 315 | } 316 | 317 | while(true){ 318 | if(b >= '0' && b <= '9'){ 319 | num = num * 10 + (b - '0'); 320 | }else{ 321 | return minus ? -num : num; 322 | } 323 | b = readByte(); 324 | } 325 | } 326 | 327 | private void tr(Object... o) { if(INPUT.length() > 0)System.out.println(Arrays.deepToString(o)); } 328 | } 329 | -------------------------------------------------------------------------------- /armstrong.py: -------------------------------------------------------------------------------- 1 | 2 | n=int(input("Enter number: ")) 3 | s = n 4 | b = len(str(n)) 5 | sum1 = 0 6 | while n != 0: 7 | r = n % 10 8 | sum1 = sum1+(r**b) 9 | n = n//10 10 | if s == sum1: 11 | print("The given number", s, "is armstrong number") 12 | else: 13 | print("The given number", s, "is not armstrong number") 14 | 15 | -------------------------------------------------------------------------------- /logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RajkumarSony/HacktoberFest2022/2268dfd80de7213007f1241365eb25e7810710f4/logo.png -------------------------------------------------------------------------------- /quickSort.java: -------------------------------------------------------------------------------- 1 | import java.util.Arrays; 2 | 3 | public class QuickSort { 4 | 5 | static void swap(int[] arr, int i, int j) { 6 | 7 | int temp = arr[i]; 8 | arr[i] = arr[j]; 9 | arr[j] = temp; 10 | } 11 | 12 | static int partition(int[] arr, int low, int high) { 13 | 14 | int pivot = arr[high]; 15 | int i = (low - 1); 16 | 17 | for(int j = low; j <= high - 1; j++) { 18 | if (arr[j] < pivot) { 19 | i++; 20 | swap(arr, i, j); 21 | } 22 | } 23 | swap(arr, i + 1, high); 24 | return (i + 1); 25 | } 26 | 27 | static void quickSort(int[] arr, int low, int high) { 28 | 29 | if (low < high) { 30 | int pi = partition(arr, low, high); 31 | 32 | quickSort(arr, low, pi - 1); 33 | quickSort(arr, pi + 1, high); 34 | } 35 | } 36 | 37 | public static void main(String[] args) { 38 | 39 | int[] arr = { 8,10,3,2,6}; 40 | int n = arr.length; 41 | 42 | quickSort(arr, 0, n - 1); 43 | System.out.println("Sorted array: " + Arrays.toString(arr)); 44 | } 45 | 46 | } 47 | --------------------------------------------------------------------------------