A2_2010_sol

# A2_2010_sol - Assignment 2 Solution Q1 a(A1 A2 A3=180...

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

Assignment 2 Solution Q1 a. (A1+A2+A3=180) AND (A1 = 90 OR A2 = 90 OR A3 = 90) AND (A1>0 AND A2 >0 AND A3> 0) b. ((MY % 2 == 0) && (CY % 2 == 1)) && ((CY - MY > 4) && (CY- MY <=22)) Q2 a. GIVENS: RESULTS: INTERMEDIATES: HEADER: ASSUMPTIONS: CONSTRAINTS: BODY: Type DetermineType(Side1, Side2, Side3) Side1, Side2, Side3 (the sides of a triangle) Type (a string that holds the type of the triangle) (Side1 = Side2) AND (Side2 = Side3) false true Type = Equilateral (Side1 + Side2 <= Side3) OR (Side1 + Side3 <= Side2) OR (Side2 + Side3 <= Side1) false true Type = Invalid (Side1 = Side2) OR (Side1 = Side3) OR Side2 = Side3 false true Type = Other Type = Isosceles 1 2 3 4 5 67 Alternatively, you could determine which side is the longest, then test if the sum of the other two sides is <= the longest side. The test would have only one inequality.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
b. 3 Side1 “Other” 6. Type = “Other” 4. (Side1 = Side2) OR (Side1 = Side3) OR (Side2 = Side3) ? False 5 Side3 6 Side2 2. (Side1 + Side2 <= Side3) OR (Side1 + Side3 <= Side2) OR (Side2 + Side3 <= Side1) ? False 1. (Side1 = Side2) AND (Side2 = Side3) ? False ? initial values Result statements Q3 /**
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 6

A2_2010_sol - Assignment 2 Solution Q1 a(A1 A2 A3=180...

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

View Full Document
Ask a homework question - tutors are online