To enhance the correctness of function logic, professional programmers often pla
ID: 3713915 • Letter: T
Question
To enhance the correctness of function logic, professional programmers often place "precondition" to check the validity of all the parameter values given to a function and also place "postcondition" to verify a computed result to be proper or not before returning to a caller.
Suppose that you need to develop a function triangleArea(s1, s2, s3) will return the area of the triangle formed by the three side s1, s2, and s3. What kind of precondition and postcondition can you add to this function? You do not need to write a program but indicate what conditions to add.
Explanation / Answer
.
Postcondition: The input became sides of triangle (s1,s1,s3)
Postcondition: The perimeter and area are calculated. With help of sides. Then the results must be displayed to user along with inputs.
Precondition: The user mut enter input 3 number to program . The inputs must be positive else program need to ask user to re enter or progepr need to terminate based on requirement . mRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.