#include <stdio.h>
//********************************************************
// Function: irishLicensePlateValidator
//
// Purpose: Checks the validity of an Irish License Plate
//
// Parameters: year - 2 digit year license was issued
// halfYear - half year period car was sold in
// county - the irish county the car was
// registered
// snumber - 1-6 digit sequence number
//
// Returns: int
//********************************************************
int irishLicensePlateValidator(int year, int halfYear, char county, int snumber)
{
char validCounties[] = {'c', 'C', 'd', 'D', 'g', 'G', 'l', 'L', 't', 'T', 'w', 'W'}; // array of valid county abbreviations
int i; // loop index
// varying conditions that test validity:
// - if any of the conditions are met, the code stops and returns a 0 to indicate the plate is not valid
// - if none of the conditions are meet, the code goes all the way through and returns a 1 to indicate the plate is valid
// check to see if the year is between 13 and 24
if (year < 13 || year > 24)
{
return 0;
}
// check to see if the half-year period is 1
// if not, check to see if it is 2
if (halfYear != 1)
{
if (halfYear != 2)
{
return 0;
}
}
// A loop to check the character vs the validCounties array
// Alternatively, you could also do this with a series
// of checks within a switch statement as well
for (i = 0; i < 12; ++i)
{
if (validCounties[i] == county)
{
break;
}
}
// if all country codes were checked, and nothing matched
// the country code would be 12 at this point, and would
// indicate that the country code is invalid
if (i == 12)
{
return 0;
}
// since the maximum is 6 digits, the number cannot be higher than 999999
// and can't be less than zero as well. 1 is the lowest number
if (snumber <= 0 || snumber > 999999)
{
return 0;
}
// if the compiler makes it all the way here, the plate must be valid and
// therefore returns TRUE (which is a value of 1)
return 1;
} //irishLicensePlateValidator
int main(void) {
// your code goes here
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgovLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCi8vIEZ1bmN0aW9uOiBpcmlzaExpY2Vuc2VQbGF0ZVZhbGlkYXRvcgovLwovLyBQdXJwb3NlOiBDaGVja3MgdGhlIHZhbGlkaXR5IG9mIGFuIElyaXNoIExpY2Vuc2UgUGxhdGUKLy8KLy8gUGFyYW1ldGVyczogeWVhciAtIDIgZGlnaXQgeWVhciBsaWNlbnNl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