Program 2 Comments

CS-150, Fall ’02, Dr. C. S. Tritt

 

Scores were generous. The average was 92 with a range of 75 to 100.

 

I generally counted 10 points per section (Folder, Cover Page, Introduction, Instructions, I/O Description, Algorithm Description (including pseudocode & flowchart), Test Results, Source Code, Build Log and Internal Documentation (indentation & comments).

 

Don’t you magic numbers. Use const double g = 9.81 // gravitational acceleration in m/s^2 near the beginning of your program rather than putting 9.81 in your equations. What if you were suddenly transported to another planet where g was 10.2 m/s2?

 

For better looking source code, use Tools | Options | Tabs to set the Tab Size to 3, the Indent Size to 3 and select Insert Spaces. Don’t do this for existing projects.

 

Many people use Vy2/(2g) to determine if the projectile cleared the wall. This is incorrect. I think this equation of for the maximum height reached by a projectile. You need the height when the projectile was at Xwall. The equation for this was given as y(Xwall) = -gXwall2/(2Vx,02) + (Vy,0/Vx,0)Xwall. I note that this equation implies the trebuchet must be at least  as far back from the wall as the wall is high when the launch angle is 450 (since then Vy,0= Vx,0). This indicates the need to analyze and understand your problem before attempting to write a program to solve it.

 

Remember to include units for all variables. At least one student used 32.2 ft/s2 for g.

 

Remember to comments on all test results. If they were what you expected, say so. Explain or at least note any unusual or unexpected results. Several students had your test results match the program results, but both were wrong. These students used the same, incorrect, equations for both. This indicates the need for independent evaluation of program. The only way to be sure this program was working would be to build a trebuchet and try it.