Advertisement
pleasedontcode

"Employee Management" rev_01

Dec 1st, 2024
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********* Pleasedontcode.com **********
  2.  
  3.     Pleasedontcode thanks you for automatic code generation! Enjoy your code!
  4.  
  5.     - Terms and Conditions:
  6.     You have a non-exclusive, revocable, worldwide, royalty-free license
  7.     for personal and commercial use. Attribution is optional; modifications
  8.     are allowed, but you're responsible for code maintenance. We're not
  9.     liable for any loss or damage. For full terms,
  10.     please visit pleasedontcode.com/termsandconditions.
  11.  
  12.     - Project: "Employee Management"
  13.     - Source Code NOT compiled for: Arduino Uno
  14.     - Source Code created on: 2024-12-01 18:31:00
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* There is a structure called employee that holds */
  21.     /* information like   employee code, name, and date */
  22.     /* of joining. Write a program to create   an array */
  23.     /* of structures and enter some data into it. Then */
  24.     /* ask the user to   enter current date. Display the */
  25.     /* names */
  26. /****** END SYSTEM REQUIREMENTS *****/
  27.  
  28. /* START CODE */
  29.  
  30. /****** DEFINITION OF LIBRARIES *****/
  31. // No standard input/output libraries like <stdio.h> or <conio.h> are available in Arduino
  32. // #include<stdio.h>
  33. // #include<conio.h>
  34.  
  35. /****** FUNCTION PROTOTYPES *****/
  36. void setup(void);
  37. void loop(void);
  38.  
  39. struct employee
  40. {
  41.     int code;
  42.     char name[30];
  43.     int doj[3]; // Date of joining: day, month, year
  44. } hcl[50] = {
  45.     {1, "Shahnawaz", {13, 1, 2006}},
  46.     {4, "Amit Puri", {21, 6, 2008}},
  47.     {102, "Irfan Moin", {12, 5, 2012}},
  48.     {131, "Shabnam", {16, 1, 2014}}
  49. };
  50.  
  51. // Function prototype for printinfo
  52. void printinfo(struct employee k);
  53.  
  54. void setup(void)
  55. {
  56.     // Initialize serial communication
  57.     Serial.begin(9600);
  58. }
  59.  
  60. void loop(void)
  61. {
  62.     int d[3];
  63.     // For demonstration, we will use a fixed date
  64.     d[0] = 15; // day
  65.     d[1] = 10; // month
  66.     d[2] = 2023; // year
  67.  
  68.     Serial.println("\nEmployees with greater than or equal to 3 years of tenure\n");
  69.     for (int i = 0; i < 4; i++)
  70.     {
  71.         if (d[2] - hcl[i].doj[2] > 3)
  72.             printinfo(hcl[i]);
  73.         else if (d[2] - hcl[i].doj[2] == 3)
  74.         {
  75.             if (d[1] - hcl[i].doj[1] > 0)
  76.                 printinfo(hcl[i]);
  77.             else if (hcl[i].doj[1] == d[1])
  78.             {
  79.                 if (d[0] - hcl[i].doj[0] >= 0)
  80.                     printinfo(hcl[i]);
  81.             }
  82.         }
  83.     }
  84.    
  85.     // Add a delay to avoid flooding the serial output
  86.     delay(10000); // Wait for 10 seconds before repeating
  87. }
  88.  
  89. void printinfo(struct employee e)
  90. {
  91.     Serial.print("\nCode : ");
  92.     Serial.println(e.code);
  93.     Serial.print("Name : ");
  94.     Serial.println(e.name);
  95.     Serial.print("Date of joining : ");
  96.     Serial.print(e.doj[0]);
  97.     Serial.print("-");
  98.     Serial.print(e.doj[1]);
  99.     Serial.print("-");
  100.     Serial.println(e.doj[2]);
  101. }
  102.  
  103. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement