{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

TimLinHW02

# TimLinHW02 - BEE 1510 Introduction to Computer Programming...

This preview shows pages 1–2. Sign up to view the full content.

% BEE 1510 Introduction to Computer Programming % Homework Exercise 02: Control Structures % Timothy Lin % % Record of revisions: % original code: September 23, 2008 % last modified: September 24, 2008 % % Variable Dictionary % soil = which type of soil being dealt with % f_w = water fraction % f_s = soil fraction % cp_org = specific heat of organic soil in J/kg-K % cp_min = specific heat of mineral soil in J/kg-K % class = soil class determined by sand, silt, clay fractions % % Clear command window before program starts clc c % Ask user for soil type soil = menu('Enter soil type','Organic','Mineral','Mineral - skip specific heat calculation'); c % Do specific heat calculation if Organic or Mineral was chosen from menu if (soil == 1) | (soil == 2) i % Ask user for input of soil fraction f_s = input('Enter the soil fraction: \n'); f % Check if soil fraction is appropriate % If input < 0.3 or input > 0.8 for soil fraction, program will be terminated if f_s < 0.3 | f_s > 0.8 error('This value for the soil fraction is unlikely for the soil fraction is unlikely to be less than 0.3 or greater than 0.8. Program terminated') % Display soil fraction that was input else fprintf('The soil fraction is %f. \n', f_s)

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}