Programming 4

# Programming 4 - Problem Source: Programming 4 Problem 1...

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

Problem Source: Programming 4 Problem 1 Given: Number of prisms, Length, shape of prism, radius/side length Required: Volume of prism Diagram: Solution: %Nathaniel Tran 16184-York N=input( 'Enter the number of prisms: ' ); for J=1:1:N shape=input( 'Specify prism type (1)circular (2)square (3)triangular: ' ); units=input( 'Specify units: ' , 's' ); L=input( 'Specify length: ' ); if shape==1 R=input( 'Enter radius: ' ); V=(pi*R*R*L); fprintf( 'Circular, Radius: %f %s, Length: %f %s, Volume: %f %s squared \n' , R, units, L, units, V, units) else if shape==2; W=input( 'Enter width: ' ); V=(W*W*L); fprintf( 'Square, Width: %f %s, Length: %f %s, Volume: %f %s squared \n' , W, units, L, units, V, units) else W = input( 'Enter width: ' ); V=(0.5*W*W*sin(pi/3)*L); fprintf( 'Triangular, width: %f %s, Length: %f %s, Volume: %f %s squared \n' , W, units, L, units, V, units) end end end Test Run: Enter the number of prisms: 3 Specify prism type (1)circular (2)square (3)triangular: 1 Specify units: cm

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.

## This note was uploaded on 03/30/2008 for the course ENGE 1024 taught by Professor Dcohanehi during the Fall '06 term at Virginia Tech.

### Page1 / 4

Programming 4 - Problem Source: Programming 4 Problem 1...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online