Q:

The conversion depends on the temperature and other factors, but an approximation is that 1 inch of rain is equivalent to 6.5 inches of snow. W

0

 The conversion depends on the temperature and other factors, but an approximation is that 1 inch of rain is equivalent to 6.5 inches of snow. Write a script that prompts the user for the number of inches of rain, calls a function to return the equivalent amount of snow, and prints this result. Write the function, as well! 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Ch3Ex33.m

% Prompt the user for a number of inches of rain

% and call a function to calculate the 

% equivalent amount of snow

rain = input('How much rain in inches: ');

snow = rainToSnow(rain);

fprintf('%.1f inches of rain would be ', rain)

fprintf('%.1f inches of snow\n', snow)

 

 rainToSnow.m

function outsnow = rainToSnow(rain)

% Calculate equivalent amount of snow

% given rainfall in inches

% Format of call: rainToSnow(rain)

% Returns equivalent snowfall

outsnow = rain * 6.5;

end

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now