Electrical and Computer Engineering
11 of 12
UAH
CPE 112
Using a Value-Returning
Function for Input
•Animals StrToAnimal (/*in*/ string str)
•{
•  Animals inPatient;
•  switch (toupper(str[0]))
•  {
•     case ‘R’ : if (toupper(animalName[1] == ‘O’)
•                   inPatient = RODENT;
•                else
•                   inPatient = REPTILE;
•                break;
•     case ‘C’ : inPatient = CAT;
•                break;
•     case ‘D’ : inPatient = DOG;
•                break;
•                  .
•                  .
•                  .
•     return inPatient;
•  }
•}
•  
•