fork download
  1. #include <stdio.h>
  2. #include <ctype.h>
  3. int irishLicensePlateValidator(int year, int halfYear, char county, int sequenceNumber);
  4.  
  5. int main(void) {
  6. // your code goes here
  7.  
  8. int result = irishLicensePlateValidator(13, 2,'c',00000000124);
  9. printf ("%d", result);
  10. }
  11.  
  12. int irishLicensePlateValidator(int year, int halfYear, char county, int sequenceNumber)
  13. {
  14.  
  15. // you can get most all values you need from the parameter values passed in
  16. //year: check if they are between 2013-2024. if yes take only the last 2 numbers
  17. // halfYear: check if it's 1 or 2
  18. //county: accept 'C' or 'c' for "Cork", 'D' or 'd' for "Dublin", 'G' or 'g' for "Galway", 'L' or 'l' for "Limerick", 'T' or 't'
  19. // for "Tiperary", and 'W' or 'w' for "Waterford".
  20. // sequenceNumber: check that it doesn't start w 0, its all numbers, and its 6 or less digits
  21.  
  22. // add some conditional statement logic to check each parameter (switches, if/else, ...)
  23. if (!(year >= 13 && year <= 24)) //check if year is
  24. {
  25. return 0;
  26. }
  27. if (!(halfYear == 1 || halfYear == 2))
  28. {
  29. return 0;
  30. }
  31. switch (toupper (county))
  32. {
  33. case 'C':
  34. case 'D':
  35. case 'G':
  36. case 'L':
  37. case 'T':
  38. case 'W':
  39. break;
  40. default:
  41. return 0;
  42. } // switch
  43. if (!(sequenceNumber >= 1 && sequenceNumber <= 999999))
  44. {
  45. return 0;
  46. }
  47. return 1;
  48. // return either 1 or 0 ... for T/F
  49.  
  50. }
Success #stdin #stdout 0s 5280KB
stdin
Standard input is empty
stdout
1