HO-ProblemSolvingExample.doc Page 1 of 3 1/19/05 METBD 050 Algorithm Example: Given the material of a cylinder (aluminum or steel), as well as the height and weight of the cylinder, write an algorithm to determine the diameter of the cylinder. The unit weight of aluminum is 0.10 lbs/in3 and for steel, the unit weight is 0.28 lbs/in3. ITO Chart: Input Transformation Output Material Height, h Weight, w 1. Get the material, m 2. Get the height, h 3. Get the weight, w 4. If m = “Aluminum” Then Gamma = 0.10 Else Gamma = 0.28 End If 5. Calculate the Volume, V V = w / Gamma 6. Find Area of the Cylinder End: A = V / h 7. Find the Diameter of the Cylinder: D = (4 * A / 3.1415926)^0.5 8. Display the Diameter. 9. End Diameter, D Problems Encountered: 1. The program depends on the user to input values using the proper units. 2. The user can input any material. The default unit weight is .28 lbs/in3 in the case of any other specified material. May want to include another step: 3a. If m <> “Aluminum” OR m <> “Steel” Then Display Error Message: “Material must be Steel or Aluminum” END End If This step checks that the material is steel or aluminum and displays an error message is it is not. The program then stops. hDiameter, DHO-ProblemSolvingExample.doc Page 2 of 3 1/19/05 Flowchart for the Algorithm: D = (4 * A / 3.1415)^.5 A = V / h StartGamma = 0.10 Get material, m Get Height, h Get Weight, w Is m = “Aluminum”?YESNO Gamma = 0.28 V = w / Gamma Display the value of the diameter ENDHO-ProblemSolvingExample.doc Page 3 of 3 1/19/05 Excel Solution to the Problem: NOTES: 1. I gave the sheet a title and a description. This way, I can come back to this worksheet later and quickly know what it does. 2. Cell formulas are shown in RED. 3. The input cells are filled with a yellow color. 4. Labels are used to identify what quantities to place in cells. 5. Unit labels are provided for the inputs where appropriate. 6. The material in cell C8 is selected from a drop-down list. I used the validation tool under the Tools menu to build this list. Only the materials on the list can be selected. 7. In cell C15, note the use of the PI() function which is used to return the value of π. 8. The IF function is used to determine the value of gamma by comparing the specified material, m to “Aluminum”. If the material IS aluminum, gamma is 0.10. If the material IS NOT aluminum, it must be steel since we only have two choices and gamma is
View Full Document