Levels Tought:
Elementary,Middle School,High School,College,University,PHD
Teaching Since: | May 2017 |
Last Sign in: | 305 Weeks Ago, 4 Days Ago |
Questions Answered: | 66690 |
Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
Write a function called older that takes as its input arguments six positive scalar integers: y1, m1, d1, y2, m2, d2, in that order, representing the birthdates of two persons. The variables that start with y stand for the year, m for the month and d for the day. The variables that end in 1 correspond to the first person, while those that end in 2 correspond to the second person. The function returns 1 if the first person is older, 0 if they have the same age, and -1 if the first person is younger
You do not need to check whether the inputs have appropriate values. For example, you may assume that both m1 and m2 are positive integers that are less than 13 and that the day numbers fit with their months.
Â
Answer
function a = older(y1,m1,d1,y2,m2,d2)
a = 1;
if y1 == y2 && m1 == m2 && d1 == d2
a = 0;
elseif (y1 > y2) || (y1 == y2 && m1 > m2) || (y1 == y2 && m1 == m2 && d1 > d2)
a = -1;
end
end
Hel-----------lo -----------Sir-----------/Ma-----------dam----------- Â----------- Th-----------ank----------- Yo-----------u f-----------or -----------usi-----------ng -----------our----------- we-----------bsi-----------te -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill-----------