fork download
  1. #include <stdio.h>
  2.  
  3. // **************************************************
  4. // Function: validateIrishLicense
  5. //
  6. // Description: Validates the components of an Irish
  7. // license plate based on the input
  8. // parameters
  9. //
  10. //
  11. // Parameters: year - last two digits of year
  12. // halfYear - 1 for Jan-Jun, 2 for Jul-Dec
  13. // countyCode - a value that represents the
  14. // Irish county
  15. // seqNum - a 1 to 6 digit number
  16. //
  17. // Returns: True: valid (1) or False: invalid (0
  18. //
  19. // ***************************************************
  20.  
  21. #include <ctype.h> // for topper
  22.  
  23. int validateIrishLicPlate(int year, int halfYear, char countyCode, int sequenceNumber)
  24. {
  25.  
  26. int valid = 0; // default the license plate to a false value, for invalid
  27.  
  28. if (year >= 13 && year <= 24) //validates year (needs to be between 13 and 24, including those years)
  29.  
  30. if (halfYear == 1 || halfYear == 2) //validates the half-year (should be 1 or 2 to be true)
  31.  
  32. if (sequenceNumber >= 1 && sequenceNumber <= 999999) //validate seq.# is between 1 and 999999
  33. {
  34. // if we got this far, do a final check for a valid Country Code
  35. // Converting to upper case first allows for less overall checks
  36.  
  37. switch (toupper(countyCode))
  38. {
  39. case 'C': // for Cork county
  40. case 'D': // for Dublin county
  41. case 'G': // for Galway county
  42. case 'L': // for Limerick county
  43. case 'T': // for Tipperary county
  44. case 'W': // for Waterford county
  45. valid = 1; // if county is a valid code, break and continue check
  46. default:
  47. break; // do nothing, valid will remain 0
  48. }
  49. }
  50.  
  51.  
  52. return valid; //if license plate passes all checks, plate is valid
  53.  
  54. }
  55. int main(void) {
  56. // your code goes here
  57. return 0;
  58. }
  59.  
Success #stdin #stdout 0s 5332KB
stdin
Standard input is empty
stdout
Standard output is empty