On the first day of Christmas, my true love gave to me...

edited 2015-12-06 21:32:40 in General
day = input('Which day of Christmas is it? ');

disp(' ')

switch day
case 1
disp('On the 1st day of Christmas,')
case 2
disp('On the 2nd day of Christmas,')
case 3
disp('On the 3rd day of Christmas,')
otherwise
fprintf('On the %ith day of Christmas,\n',day)
end

disp('my true love gave to me...')
disp(' ')

if day == 1
disp('A partridge in a pear tree.')
else
while day >= 2
switch day
case 12
disp('12 drummers drumming')
case 11
disp('11 pipers piping')
case 10
disp('10 lords a-leaping')
case 9
disp('9 ladies dancing')
case 8
disp('8 maids a-milking')
case 7
disp('7 swans-a-swimming')
case 6
disp('6 geese-a-laying')
case 5
disp('5 golden rings')
case 4
disp('4 calling birds')
case 3
disp('3 french hens')
case 2
disp('2 turtle doves')
end
disp(' ')
day = day - 1;
end
disp('...and a partridge in a pear tree.')
end

Comments

Sign In or Register to comment.