Question

During the past decade ocean levels have been rising faster than in the past, an average...

During the past decade ocean levels have been rising faster than in the past, an average of approximately 3.1 millimeters per year. Write a program that computes how much ocean levels are expected to rise during the next 15 years if they continue rising at this rate. Display the answer in both centimeters and inches.

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

Please find below required MATLAB code along with necessary details in comments:

function rise_in_oceanLevel(yrs)
% INPUT:
% yrs: no. of years for which rise to be computed

for i=1:yrs
RiseMM(i) = 3.1 *yrs; % total rise in MM
RiseCM(i) = RiseMM(i) * 0.1; % % total rise in CM
RiseIn(i) = RiseMM(i) * 0.0393701; % total rise in Inches
end

% display the result
disp('During the next 15 years ocean levels are expected to rise:');
fprintf(' %3.4f centmeters per year.',RiseCM(i));
fprintf(' %3.4f inches per year.',RiseIn(i));
end

========================================= main script to call the above function

clear all; clc; close all;

yrs=15;
rise_in_oceanLevel(yrs); % call the function

============================== SCREENSHOT OF CODE

main-script.m XI rise_in_oceanLevel.m X1+1 1 function risein ceanLevel (yrs) - 白% INPUT: yrs : no. of years for which rise to

main script.m Xrise_in_oceanLevel.m+ 1clear al1 clc: close all: 3- yrs=15; riseinoceanLevel (yrs); 롬 call the function - -

===================================== SAMPLE OUTPUT

Command Window During the next 15 years ocean levels are expected to rise: 4.6500 centmeters per year f 1.8307 inches per yea

Add a comment
Know the answer?
Add Answer to:
During the past decade ocean levels have been rising faster than in the past, an average...
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