Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question
100%

COSC 1336 – Programming Fundamentals I
Program 7 – Repetition Structures and Files

Python Programming

Please read till the end before answering!!!

I got the answer but need this to be added.

"Follow these requirements.

Needs percentage applied and Raise the amount of each salary displayed. So that one could be sure of the raised salary.

The total amount of Salary and Total of Raised salary should be displayed at the end."

 


The trustees of a small college are considering voting a pay raise for their faculty members. They want to grant a 7 percent raise for those earning more than $50,000.00, a 4 percent raise for those earning more than $60,000.00 and 5.5 percent raise for all others. However before doing so, they want to know how much this will cost. Write a program that will print the pay raise for each faculty member, the total amount of the raises, and the average of the raises. Also, print the total faculty payroll before and after the raise. Use the end of file as a sentinel value. The input data is available in program_7.png
Do NOT use any logical operator in the program. 
Run your program with the input file, program7.txt

 

IMPORTANT!!!

Here is the answer which needs to be modified and add

percentage applied and Raise the amount of each salary displayed. So that one could be sure of the raised salary.

The total amount of Salary and Total of Raised salary should be displayed at the end:

def main():

 

# Variable to count the total Faculty member

totalFaculty = 0

 

# Variable to count the total raised amount

raiseTotal = 0.0

 

# Display statement

print("The pay raise for each faculty member is:")

 

# Display Faculty payroll before and After the raise statement

print("Faculty payroll before \t After the raise")

 

# Open the file

inFile = open('program7.txt', 'r');

 

# Read the line

lineRead = inFile.readline()

 

# While the lineRead is not empty

while lineRead != '':

# Split the words

words = lineRead.split()

 

# For every word in the words

for word in words:

#get the number

num = float(word)

 

# For the earning of more than $60,000.00

if (num > 60000):

 

# Calculate raised salary

salaryRaise = num * 0.04

 

# For the earning of more than $50,000.00

elif (num > 50000):

 

# Calculate raised salary

salaryRaise = num * 0.07

# For the other earnings

else:

 

# Calculate raised salary

salaryRaise = num * 0.055

 

# Calculate the total raised amount

raiseTotal = raiseTotal + salaryRaise

 

# Display old and raised salary with 2 decimal format

print(format(num, '.2f'), "\t\t", format((num + salaryRaise), '.2f'))

 

# Count the total Faculty member

totalFaculty = totalFaculty + 1

 

# Read the line

lineRead = inFile.readline()

 

# Close the file

inFile.close()

 

# Display the total raises amount

print("The total amount of the raises is ", format(raiseTotal, '.2f'))

 

# Display the average of the raises amount

print("The average of the raises is ", format((raiseTotal / totalFaculty), '.2f'))

 

# Call the main function.

main()

 

Use sep='' , ',.2f' where needed.

expand button
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education