Hi everyone;
I am going to make a function that takes starting timing of two movies.like hr1,hr2,min1,min2,and their durations, durnmin1,durmin2 and decides whether we can binge and watch both movies. The criteria are that they must not overlap and that we are not going to wait more than 30 minutes between the end of one and the beginning of the next. It returns true if the criteria are both met and returns false otherwise. You may assume that movie start times are always after 1 pm and before midnight. You may also assume that the first one starts earlier. The order of the input arguments is: hr1, min1, durmin1, hr2, min2, durmin2.
I am unable to understand what will my function will do.what are these timing hr1,hr2? why duration has been given.In that function what i have to do...Thanks in advance for assistance

 Akzeptierte Antwort

Walter Roberson
Walter Roberson am 22 Mai 2015

0 Stimmen

You need to add the first duration to the first start time in order to figure out when the first one ends. Then you need to figure out how much time there is between the projected end time of the first one, and the start of the second. If the second one would start before the first one is projected to end then they overlap. If the second one would start more than 30 minutes after the first one is projected to end then they are too far apart to be desired.

5 Kommentare

Muhammad Usman Saleem
Muhammad Usman Saleem am 23 Mai 2015
@Walter thanks for contributions. I explain what i understand the question. hr1,hr2,min1,min2 are the timings for which we want to watch movies. to me dur1 and dur2 are the their durations. But i am getting confuse in what i have to do? i am using if statement with some conditions( difference between the movies times is greater than 30 mins and h2-h1 is not equal to 0--to me this is actually completing the statement movies must not overlap.I am sharing with you my codes please check and tell i need corrections..Thanks in advance
function mymovies=movies(hr1,min1,dur1,hr2,min2)
h1=hr1+min/60+dur1;
h2=hr2+min/60;
if h2-h1>=30/60 && h2-h1~=0
disp('Ture')
else
disp('False')
end
end
Muhammad Usman Saleem
Muhammad Usman Saleem am 23 Mai 2015
when i run these codes i getting an error..check whether i am doing correct which the question ask from me or not. If i am doing correction guide me where i need corrections.Thanks in advance for assistance
Walter Roberson
Walter Roberson am 23 Mai 2015
You did not check for the case where the second one starts before the first one ends.
Muhammad Usman Saleem
Muhammad Usman Saleem am 24 Mai 2015
I do not get you assistance. I think you are saying me to change if h2-h1>=30/60 && h2-h1~=0 that??

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Graphics Performance finden Sie in Hilfe-Center und File Exchange

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by