Question

Function Name: ​fluxCapacitor Inputs: 1. (double) The current year 2. (double) Destination year 3. (double) Speed,...

Function Name: ​fluxCapacitor

Inputs:

1. (double) The current year

2. (double) Destination year

3. (double) Speed, in miles per hour

Outputs:

1. (char) String stating whether you’re going back or forward into the future

Background: Doc Brown has invited you on an adventure through time. As you two hop into the time-travelling Delorean, he inputs the current year and the destination year. As the Doc steps on the gas, he reminds you that you can’t interact with ANYONE, or you’ll risk changing the flow of time itself! Midway through the speech, he realizes that the car might not reach the necessary speed to travel through time, so you'll need to quickly determine if you'll make it through time.

Function Description:

Write a function that takes in the current year, a destination year, and the max speed that the car can reach on the runway. Using these values, determine whether you’ll be going back in time, to the future, or straight into a building if the speed is less than 88 mph.

● If you're going forward in time, output: 'We're going to the year , to the future!!!'

● If you’re going back in time, output: 'We're going to the year , back in time!!!'

● If you're going under 88 mph, you won't be able to time travel, so output: 'Time traveling is just too dangerous. Better that I devote myself to study the other great mystery of the universe: MATLAB!'

Example:

out = fluxCapacitor(2008, 3000, 89);

>>out => 'We're going to the year 3000, to the future!!!'

Notes:

● The current year and destination year will never be the same.

● To create a character vector with an apostrophe, use two apostrophes in a row. Hints:

● Use the values from the first movie for a sweet surprise!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

function out=fluxCapacitor(sdate,endate,speed)

diff=endate-sdate;

if(speed>88)

if(diff>0)

out=sprintf('We''re going to the %d,to the future!!!',endate);

else

out=sprintf('We''re going to the %d,back in time!!!',endate);

end

else

out='Time traveling is just too dangerous. Better that I devote myself to study the other great mystery of the universe: MATLAB!';

end

end

Expected output:

>>out fluxCapacitor (2008,3000, 89) out- Were going to the 3000,to the future!!!

Add a comment
Know the answer?
Add Answer to:
Function Name: ​fluxCapacitor Inputs: 1. (double) The current year 2. (double) Destination year 3. (double) Speed,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT