In this exercise you'll be writing code to create name badges for factory employees to wear. Employees have an ID, name, and department name. Employee badge labels are formatted as follows: "[id] - name - DEPARTMENT".
Implement the print_name_badge function. It should take an ID, name, and a department. It should return the badge label, with the department name in uppercase.
julia> print_name_badge(67, "Katherine Williams", "Strategic Communication")
"[67] - Katherine Williams - STRATEGIC COMMUNICATION"Due to a quirk in the computer system, new employees occasionally don't yet have an ID when they start working at the factory. As badges are required, they will receive a temporary badge without the ID prefix.
Extend the print_name_badge function. When the id is missing, it should create a badge without it.
julia> print_name_badge(missing, "Robert Johnson", "Procurement")
"Robert Johnson - PROCUREMENT"Even the factory's owner has to wear a badge at all times. However, an owner does not have a department and never will: they are above all the departments. In this case, the label should return "OWNER" instead of the department name.
Extend the print_name_badge function. When the department is nothing, assume the badge belongs to the company owner.
julia> print_name_badge(204, "Rachel Miller", nothing)
"[204] - Rachel Miller - OWNER"Note that it is possible for the owner to also be a new employee.
julia> print_name_badge(missing, "Rachel Miller", nothing)
"Rachel Miller - OWNER"As a rough metric of how well the IDs are being issued, you want to see the combined salary of employees with no ID. A high value means lots are waiting, or the problem is affecting senior people: both bad.
Implement the salaries_no_id function that takes a vector of IDs and a corresponding vector of salaries, and returns the sum of salaries for people with no ID yet. Both vectors are the same length.
julia> ids = [204, missing, 210, 352, missing, 263]
julia> salaries = [23, 21, 47, 35, 17, 101] * 1000
julia> salaries_no_id(ids, salaries)
38,000In this exercise you'll be writing code to create name badges for factory employees to wear. Employees have an ID, name, and department name. Employee badge labels are formatted as follows: "[id] - name - DEPARTMENT".
Implement the print_name_badge function. It should take an ID, name, and a department. It should return the badge label, with the department name in uppercase.
julia> print_name_badge(67, "Katherine Williams", "Strategic Communication")
"[67] - Katherine Williams - STRATEGIC COMMUNICATION"Due to a quirk in the computer system, new employees occasionally don't yet have an ID when they start working at the factory. As badges are required, they will receive a temporary badge without the ID prefix.
Extend the print_name_badge function. When the id is missing, it should create a badge without it.
julia> print_name_badge(missing, "Robert Johnson", "Procurement")
"Robert Johnson - PROCUREMENT"Even the factory's owner has to wear a badge at all times. However, an owner does not have a department and never will: they are above all the departments. In this case, the label should return "OWNER" instead of the department name.
Extend the print_name_badge function. When the department is nothing, assume the badge belongs to the company owner.
julia> print_name_badge(204, "Rachel Miller", nothing)
"[204] - Rachel Miller - OWNER"Note that it is possible for the owner to also be a new employee.
julia> print_name_badge(missing, "Rachel Miller", nothing)
"Rachel Miller - OWNER"As a rough metric of how well the IDs are being issued, you want to see the combined salary of employees with no ID. A high value means lots are waiting, or the problem is affecting senior people: both bad.
Implement the salaries_no_id function that takes a vector of IDs and a corresponding vector of salaries, and returns the sum of salaries for people with no ID yet. Both vectors are the same length.
julia> ids = [204, missing, 210, 352, missing, 263]
julia> salaries = [23, 21, 47, 35, 17, 101] * 1000
julia> salaries_no_id(ids, salaries)
38,000