2 You are an electrical engineer performing tests on electri
Solution
Code:
y = input(\'How many years ago the experiment has started?: \');
m = input(\'How many months ago the experiment has started?: \');
d = input(\'How many days ago the experiment has started?: \');
h = input(\'How many hours ago the experiment has started?: \');
m = input(\'How many minutes ago the experiment has started?: \');
s = input(\'How many seconds ago the experiment has started?: \');
totalSeconds = s+60*m+3600*h+86400*d+2592000*m+31104000*y;
totalHours = totalSeconds/3600;
fprintf(\'%d years, %d months, %d days, %d hours, %d minutes, %d seconds ago the experiment was startd.\ \',y,m,d,h,m,s);
fprintf(\'%d seconds ago the experiment was started.\ \',totalSeconds);
fprintf(\'%d hours ago the experiment was started.\ \',totalHours);
Output:
How many years ago the experiment has started?: 3
How many months ago the experiment has started?: 6
How many days ago the experiment has started?: 24
How many hours ago the experiment has started?: 16
How many minutes ago the experiment has started?: 34
How many seconds ago the experiment has started?: 54
3 years, 34 months, 24 days, 16 hours, 34 minutes, 54 seconds ago the experiment was startd.
183573294 seconds ago the experiment was started.
5.099258e+04 hours ago the experiment was started.
