function gen = generationXYZ(year)
if year<1966
gen = 'O';
elseif year>=1966 && year<=1980
gen = 'X';
elseif year>=1981 && year<=1999
gen = 'Y';
elseif year>=2000 && year<=2012
gen = 'Z';
elseif year> 2012
gen = 'K';
end
Search Program on this blog
Friday, 6 November 2015
Write a function called generationXYZ that takes as its only input argument one positive integer specifying the year of birth of a person and returns as its only output argument the name of the generation that the person is part of ('X', 'Y', or 'Z ') according to the table below. For births before 1966, return 'O' for Old and for births after 2012, return 'K' for Kid. Remember that to assign a letter to a variable, you need to put it in single quotes
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment