正在加载图片...
Branches and Loops (5/42 Branch:if >Water tank example: r=input('Enter the radius of the tank base(in meters):); if(r<=0), error('Radius must be positive'); end h=input('Enter the height ofthe tank(in meters):); if(h<=0), error(Height must be positive'); end w=input('Enter the amount of water(in m3):); if(w<=0), error('Amount of water must be positive'); end capacity=pi *r2 h; space capacity -w; if (space>0), disp([There is'num2str(space)'m3 extra space']); else @月停大学 disp(Tank is full'); TONGJI UNIVERSITY endBranches and Loops (5/42) Branch: if ➢ Water tank example: r = input('Enter the radius of the tank base (in meters):'); if ( r <= 0 ), error( 'Radius must be positive' ); end h = input('Enter the height of the tank (in meters):'); if ( h <= 0 ), error( 'Height must be positive' ); end w = input('Enter the amount of water (in m3):'); if ( w <= 0 ), error( 'Amount of water must be positive' ); end capacity = pi * r^2 * h; space = capacity - w; if ( space > 0 ), disp( [ 'There is ' num2str(space) 'm3 extra space' ] ); else disp( 'Tank is full' ); end
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有