{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

solution10

# solution10 - switch-case solution Enter the displacement of...

This preview shows page 1. Sign up to view the full content.

6/27/08 12:38 PM C:\Program Files\MATLAB704\work\ENME217_07_Ass10Sol.m 1 of 1 % Assignment # 10 disp('switch-case solution') x=input('Enter the displacement of the tray, x, in mm: ') S=input('Enter 1 if x<=20 mm. Enter 2 if x>20 mm. ') switch S case 1 W=1600*x case 2 W=(1600*x+1700*(x-20)) end fprintf('weight=%4.2f N\n',W) disp('if-else solution') x=input('Enter the displacement of the tray, x, in mm: ') if x<=20 W=1600*x else W=(1600*x+1700*(x-20)) end fprintf('weight=%4.2f N\n',W) disp(' ') % Calculations shown below were copied from the Command Window
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: switch-case solution Enter the displacement of the tray, x, in mm: 16 Enter 1 if x<=20 mm. Enter 2 if x>20 mm. 1 weight=25.60 N if-else solution Enter the displacement of the tray, x, in mm: 16 weight=25.60 N switch-case solution Enter the displacement of the tray, x, in mm: 23 Enter 1 if x<=20 mm. Enter 2 if x>20 mm. 2 weight=41.90 N if-else solution Enter the displacement of the tray, x, in mm: 23 weight=41.90 N...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online