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.
COSC 1336 –
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.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images