Only for the grAde

shinzynguyen
hw02.pdf

CS A131 Fall 2017 MW 6:30-8:30pm HW02 30pts Due: Tues 10/17/2017 11:59PM

Question 1: Calculate updated salary

Write a program that calculates the updated salary for an employee and takes as input their full name, employment status, current salary, and percent pay increase. The updated salary must be formatted to two decimal places.

Example of user interaction with the program:

Please enter your full name: Doug Miller

Are you employed (enter ‘y’ for yes and ‘n’ for no)? y

Please enter your current salary: 65789.87

Please enter your percent pay increase: 5

Doug Miller’s updated annual income is $69079.36

Include the following for this section:

• hw02 1.txt: a brief text file describing the design of your program limited to a few sentences, i.e. the steps required for the calculation.

• hw02 1.py: the source code file.

• hw02 1.scr: the typescript file to show that your program works with the following input: name = John Doe, employment = y, current salary = 35,042.55, percent increase = 2.1.

Question 2: Calculate updated salary from a file and save to an output file

Create the following file in your current hw02 directory named input.txt using the vi editor. The file should be as follows:

Miller

Doug

65789.87

5

Turner

Michael

75892.56

6

Livermore

Lawrence

74900.50

1

CS A131 Fall 2017 MW 6:30-8:30pm HW02 30pts Due: Tues 10/17/2017 11:59PM

6.1

Notice that each input line consists of an employee’s last name, first name, current salary, and percent pay increase. For example, in the first input line, the last name of the employee is Miller, the first name is Doug, the current salary is 65789.87, and the pay increase is 5%. Write a program that reads data from the specified file input.txt and stores the output in the file output.txt. For each employee, the data must be output in the following form:

Doug Miller $ 69079.36

Sheila Green $ 80446.11

Amit Sethi $ 79469.43

Include the following for this section:

• hw02 2.txt: a brief text file describing the design of your program limited to a few sentences, i.e. the steps required for the calculation.

• hw02 2.py: the source code file.

• hw02 2.scr: the typescript file to show that your program works with the given input file.

Create a zipped tar package file which includes both question 1 and question 2 solutions using the following command:

tar cvzf hw02.tar.gz hw02 1.txt hw02 1.py hw02 1.scr input.txt output.txt

hw02 2.py hw02 2.txt hw02 2.scr

Submit the hw02.tar.gz to blackboard by the due date on top of this page.

**this assignment is adapted from D.S. Malik

2