#include <stdio.h>
// Function prototype
int validateIrishLicense(int year, int halfYear, char county, int sequenceNumber);
// Function definition
/**
* Function Name: validateIrishLicense
*
* Function Block:
* Validates an Irish license plate based on the given parameters.
*
* @param year The two-digit year (13-24) representing 2013-2024.
* @param halfYear The half year indicator (1 for Jan-Jun, 2 for Jul-Dec).
* @param county The character representing the Irish county.
* @param sequenceNumber The sequence number (1 to 999999).
* @return 1 if the license plate is valid, otherwise 0.
*/
int validateIrishLicense(int year, int halfYear, char county, int sequenceNumber) {
// Validate year
if (year < 13 || year > 24) {
return 0;
}
// Validate half year
if (halfYear != 1 && halfYear != 2) {
return 0;
}
// Validate county
switch (county) {
case 'C': case 'c':
case 'D': case 'd':
case 'G': case 'g':
case 'L': case 'l':
case 'T': case 't':
case 'W': case 'w':
break;
default:
return 0;
}
// Validate sequence number
if (sequenceNumber < 1 || sequenceNumber > 999999) {
return 0;
}
// All validations passed
return 1;
}
int main() {
// Test cases
int retVal1 = validateIrishLicense(13, 1, 'D', 21); // Valid
int retVal2 = validateIrishLicense(13, 3, 'K', 1); // Invalid
int retVal3 = validateIrishLicense(24, 1, 'C', 1245891); // Invalid
// Print results
printf("Test case 1: %d\n", retVal1
); // Expected output: 1 printf("Test case 2: %d\n", retVal2
); // Expected output: 0 printf("Test case 3: %d\n", retVal3
); // Expected output: 0
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgovLyBGdW5jdGlvbiBwcm90b3R5cGUKaW50IHZhbGlkYXRlSXJpc2hMaWNlbnNlKGludCB5ZWFyLCBpbnQgaGFsZlllYXIsIGNoYXIgY291bnR5LCBpbnQgc2VxdWVuY2VOdW1iZXIpOwoKLy8gRnVuY3Rpb24gZGVmaW5pdGlvbgovKioKICogRnVuY3Rpb24gTmFtZTogdmFsaWRhdGVJcmlzaExpY2Vuc2UKICogCiAqIEZ1bmN0aW9uIEJsb2NrOgogKiBWYWxpZGF0ZXMgYW4gSXJpc2ggbGljZW5zZSBwbGF0ZSBiYXNlZCBvbi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