| School of Physics |
|
| Physics Home | Study here | Our Teaching | Our Research | Our Centres | News | Work here | EMPS |
Back to top
PHY3134 Exercise 3This is an assessed exercise and should be handed in next week for quick feedback. It will be returned the following week. Objectives
Overview of the taskWe ask you to write a program that includes a structure to represent a triangle. The user will type in either the lengths of two of the sides and the angle between them, or the length of one of the sides and the angles it makes with each of the other two sides. The program will then calculate the unknown sides and angles and the area of the triangle. You may want to revise the sine rule, the cosine rule and how to calculate the area of a triangle. The exerciseAnalysis (25%)This should take much less than 25% of the time so it's worth doing it well! Download the analysis document and fill it in. Feel free to add any other issues you consider to be important. We are looking for bullet points, not paragraphs of text, remember you will need to be able to glance at it whilst you are programming. You will be assessed not only for the analysis itself but also how it is reflected in your program. Program and testing (75%)Define a suitable structure for a triangle. Make it clear which angle corresponds to which pair of sides. Allow the user to enter either the lengths of two of the sides and the angle between them, or the length of one of the sides and the angles it makes with each of the other two sides. Give them the choice and do some suitable sanity-checks. Then calculate the unknown sides and angles and the area of the triangle. Use functions for self-contained tasks that make sense from a (mathematical) description of the problem. Try out the checks you described in the analysis document. Hand in
When things go wrongIf you've gone 15 minutes without making progress (outside of lab time) ask me for help, either in person or by email. Always show me the complete, latest code. |