{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

hw03_problem5

hw03_problem5 - ENGR 12600 Fall 2008 Solution to Homework 3...

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

% ENGR 12600 Fall 2008 % Solution to Homework 3, Problem 5. % This program calculates the upper and lower bounds of the number of steel balls that will fit into a cube ranging between 0.5 and 3.5 meters per side. % The students generate the code from a flowchart provided. % ---- Input Section ---- % Step 1 assigns the diameter of the steel sphere diameter = .015; % (meters) % Step 2 creates a vector with specified lengths of each side of a cube ranging from 0.5 to 3.5 m in 0.5 m increments box_dimension = [0.5:0.5:3.5]; % alternate: length = [0.5 1.0 1.5 2.0 2.5 3.0 3.5] % ---- Calculation Section ---- % Step 3 calculates a vector of volumes of each box (m^3) box_volume = box_dimension.^3; % Step 4 calculates the volume of a sphere (m^3) sphere_volume = (4/3)*pi*(diameter/2)^3; % alternate: sphere_volume = (1/6)*pi*diameter^3; % Step 5 calculates the upper bound of the number of steel spheres that % fit in each box. upper_bound = floor(box_volume/sphere_volume);

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 ]}

Page1 / 2

hw03_problem5 - ENGR 12600 Fall 2008 Solution to Homework 3...

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

View Full Document
Ask a homework question - tutors are online