fork download
  1. #include <stdio.h>
  2.  
  3. int irishLicensePlateValidator(int year, int halfYear, char county, int sequence) {
  4. // Validate year
  5. if (year < 13 || year > 24) {
  6. return 0; // Invalid year
  7. }
  8.  
  9. // Validate halfYear
  10. if (halfYear != 1 && halfYear != 2) {
  11. return 0; // Invalid halfYear
  12. }
  13.  
  14. // Validate county by checking if it is one of the valid counties
  15. switch (county) {
  16. case 'C': case 'c':
  17. case 'D': case 'd':
  18. case 'G': case 'g':
  19. case 'L': case 'l':
  20. case 'T': case 't':
  21. case 'W': case 'w':
  22. break; // Valid county
  23. default:
  24. return 0; // Invalid county
  25. }
  26.  
  27. // Validate sequence number (should be between 1 and 999999)
  28. if (sequence < 1 || sequence > 999999) {
  29. return 0; // Invalid sequence number
  30. }
  31.  
  32. // All checks passed
  33. return 1;
  34. }
  35.  
  36. int main() {
  37. int year, halfYear, sequence;
  38. char county;
  39.  
  40. // Prompt the user for input
  41. printf("Enter the year (last two digits), half-year (1 or 2), county (single character), and sequence number: \n");
  42. scanf("%d %d %c %d", &year, &halfYear, &county, &sequence);
  43.  
  44. // Output the result of the validation
  45. int result = irishLicensePlateValidator(year, halfYear, county, sequence);
  46. printf("License plate validation result: %d\n", result);
  47.  
  48. return 0;
  49. }
  50.  
Success #stdin #stdout 0.01s 5300KB
stdin
13 1 D 21
stdout
Enter the year (last two digits), half-year (1 or 2), county (single character), and sequence number: 
License plate validation result: 1