Modeling Operations - Quiz Explanation

The answers you selected are indicated below, along with text that explains the correct answers.
 
1. Compute the area of a square using the height and width. Allow no more than two digits of precision on the input. The answer should have no more than two digits of precision as well. Choose the operation notation that most accurately describes the stated requirement.
Please select the best answer.
  A. Area ( height : numeric , width : numeric ) : numeric { 2 decimals maximum }
  B. Area (width : numeric { 0 to 2 decimals } , height : numeric { 0 to 2 decimals } ) : numeric { 0 to 2 decimals }
  C. Area ( height : 2 decimals = 0 , width : 2 decimals = 0 ) : area : 2 decimals
  D. Area ( width : numeric { 0 to 2 decimals } , height : { 0 to 2 decimals } ) area : { 0 to 2 decimals }
  The correct answer is B.
Area (width : numeric{0 to 2 decimals}, height : numeric{0 to 2 decimals}) : numeric{0 to 2 decimals}. A is incorrect because it does not include the constraints for the arguments. C is incorrect because it uses the data type to specify constraints. D is incorrect because it leaves out the data types in one of the arguments and the return.

2. Determine a person's initials from their name. Choose the operation notation that most accurately describes the stated requirement.
Please select the best answer.
  A. GetInitials ( firstname : character , middlename : character , lastname : character ) : character
  B. GetInitials ( name : character ) : initials { the first letter of each name }
  C. GetInitials ( name : character { 1 to 60 characters } ) : character
  D. GetInitials (firstname : first letter , middlename : first letter , lastname : first letter ) : character { 1 to 3 characters }
  The correct answer is A.
GetInitials ( firstname : character , middlename : character , lastname : character ) : character. D is incorrect because it adds an unnecessary constraint that the result can be no more than three characters. With three inputs, it would be difficult to get more letters. Also, first letter explains the operation for finding initials, not the data type. B is incorrect because it uses the constraint notation to describe the operation rather than a constraint on the return data. C is incorrect because it includes a constraint on the input value that would typically be in the attribute definition rather than the argument definition.

3. Define an operation to locate a customer's address using the customer's unique identifier that is always an integer. Choose the operation notation that most accurately describes the stated requirement.
Please select the best answer.
  A. GetCustomerAddress ( customerid : integer ) : Address
  B. GetCustomerAddress ( customerid : integer ) : character { 2 lines of street address, city, state and zipcode }
  C. GetCustomerAddress ( customerid : unique integer ) : Address
  D. GetCustomerAddress ( customerid : unique ) : character { 2 lines of street address, city, state and zipcode }
  The correct answer is A.
GetCustomerAddress ( customerid : integer ) : Address. B is incorrect because it loads all the information describing the address into the constraints when an abstract data type would be more appropriate. C and D use the word unique, which is a constraint, in the data type element, so they are incorrect.