W06 Code-along Activity: Human Resources System
Code-along Activity Overview
For this activity, you will code along with an instructor video that walks you through each step of the activity below. Make sure that you pause the video, or watch sections over if you need to, so that you are able to complete the entire activity.
Your instructor will post a link to the video in Microsoft Teams.
Overview
Consider the scenario of a Human Resources (HR) system. It contains various information about the employees of a company, such as their names, ID numbers, job titles, salaries, etc. From this data you may need to run a payroll process to generate paychecks, generate information for tax purposes, or produce any number of reports of various kinds.
The data for these HR systems is stored on servers. In a real system, this data would be stored in a database, but for our purposes, we will practice by using data stored in a single text file.
Program Requirements
Download the file hr_system.txt. This file contains information for a set of employees. The first few lines look as follows:
Name ID Title Salary
Alexia 1913 Engineer 84000
Herman 4266 Manager 106000
Jay 5849 Engineer 93000
Ahmad 1326 Tester 85000
The format of each line is:
name id_number job_title salary
There is a single space between each field of data.
The program should iterate through each line of this file, gather the information from each field and display the values in this format: name (ID: id_number), job_title - $salary
. Don't forget to convert the salary to a number and display it with two decimals.
The following shows the first few lines of expected output at this point.
Alexia (ID: 1913), Engineer - $84000.00
Herman (ID: 4266), Manager - $106000.00
Jay (ID: 5849), Engineer - $93000.00
Ahmad (ID: 1326), Tester - $85000.00
Enhancement
Instead of displaying the salary information, calculate and display a paycheck amount for the employee. Assume that they are paid twice a month.
Then, make the program generate bonuses for anyone who is an engineer. For each of these employees, add $1000 to their paycheck amount.
The following shows sample output at the end of the enhancement:
Alexia (ID: 1913), Engineer - $4500.00
Herman (ID: 4266), Manager - $4416.67
Jay (ID: 5849), Engineer - $4875.00
Ahmad (ID: 1326), Tester - $3541.67
Ciaran (ID: 2019), Engineer - $3583.33
Callum (ID: 8005), Engineer - $4041.67
Samantha (ID: 4802), Tester - $3333.33
Antonio (ID: 1423), Tester - $2125.00
May (ID: 5575), CFO - $4666.67
Sebastian (ID: 7378), Scientist - $4250.00
Kaitlyn (ID: 4542), Support - $2625.00
William (ID: 7364), Tester - $3083.33
Sophie (ID: 3437), Engineer - $5541.67
Isaiah (ID: 1518), Designer - $2416.67
Aimee (ID: 8093), CEO - $5208.33
Patrick (ID: 2214), Sales - $3625.00
Gloria (ID: 4414), Designer - $3291.67
Joseph (ID: 9427), Sales - $3791.67
Barbara (ID: 5967), Engineer - $5333.33
Assignment
Find the video that your instructor has posted for this assignment and code along with them for each of the following steps.
Please work through the requirements in order with the instructor rather than jumping ahead to more complicated steps, to ensure that you are understanding the fundamental concepts.
Sample Solution
In addition to the instructor video, you can also view this sample solution. (This solution may be slightly different than the final code that you and your instructor created.)
Alternative Video Link
In addition to the link that your instructor posted, you are also welcome to watch the following code walkthrough or use its transcript:
- Human Resources Code-along Video (18 minutes)
Submission
Please pause and re-watch any sections of the instructor video necessary until you have completed the entire activity and your program runs the same as the instructor's. When you are finished:
- Return to Canvas to take the quiz.
Up Next
- W06 Project: Data Analysis
Other Links:
- Return to: Week Overview | Course Home