Limited access

A company needs to create an encryption key for each of its employees. They decide on a key that is composed of the employee’s social security number added to their annual salary (disregarding decimal places) plus the product of the employee’s number of years of service and their age in whole years.

For example, assume the employee’s social security number is 651712563, salary is 50,000.72, years of service is 20 years, and age is 50 years old. The encryption key would be 651712563 + 50000 + (20 x 50) = 651763563 .

After many design considerations, it has been decided to represent the data as follows:

int workYears;  //Number of years of service in whole years.
int age;        //Age in years
double salary;  //Salary in dollars
String ssn;     //Social security number without dashes
String key;     //Encryption key

Which of the following statements will format the employee’s encryption key correctly?

Note that the method Integer.parseInt will return the integer equivalent of the String passed to it.

A
key = "" + (Integer.parseInt(ssn) + (int) salary + workYears * age);
B
key = "" + (Integer.parseInt(ssn) + salary + workYears * age);
C
key = ssn + salary + workYears * age;
D
key = ssn + (int) salary + workYears * age;
E
key = "" + ((int) (ssn + salary + workYears * age));
Select an assignment template