Question

Python Note- Do not use logical operators. Please keep it simple. The trustees of a small...

Python

Note- Do not use logical operators. Please keep it simple.

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 the file as a sentinel value.

The input data is as follows:

52500.00       64029.50      56000.00      50001.00
65500.00       42800.00      45000.50      68900.00
60000.00       59999.94      54120.25      64100.00
44000.50       80100.20      90000.00      41000.00
60500.50       72000.00      50000.01      50000.00
80001.75       60001.00

Here is the template given for this program:

def main():
  
inFile = open('program7.txt', 'r')
  
lineRead = inFile.readline()
while lineRead != '':
words = lineRead.split()
for word in words:
num = float(word)
print(format(num, '.2f'))
  
lineRead = inFile.readline()

# Close the file.
inFile.close()
  
# Call the main function.
main()

Homework Answers

Answer #1

Here i am providing the answer. Hope it helps. please give me a like. it helps me a lot.

Note:

  • "Screen shot of the code" for better understanding.
  • "Code to copy" for run the program in your IDE.
  • Please follow the code indentation properly to avoid indentation errors.

Code Image:

Input File Image:

Sample Output:

Code to Copy:

#Implementation of main method

def main():

   #Declare totalRaise and

   #assign as 0

   totalRaise = 0

   #Declare facultyCount and

   #assign as 0

   facultyCount = 0

   #Display statement

   print("pay raise for each faculty member ")

   #Display statement for Old salary and Raised Salary

   print("\n%-15s %-15s\n"%("Old Salary", "Raised Salary"))

   #open the file in read mode

   fileread = open("d:\\facultymembers\\pay.txt", "r")

   #read the lines of file

   filedata = fileread.readlines()

   # Iterate the file and

   for eachline in filedata:

       # Split the on space

       content = eachline.strip().split()

       #using the sentinel value

       #check the up to value is empty

       if content!='':

           # Iterating over each salary

           for eachSalary in content:

               #convert eachsalary into float

               eachSalary = float(eachSalary)

               # if the salary range is greater than 60000

               # calculate the raise salary

               if eachSalary > 60000:

                   raiseSalary = eachSalary * (4/100.0)

               # if the salary range is greater than 50000

               # calculate the raise salary

               elif eachSalary > 50000:

                   raiseSalary = eachSalary * (7/100.0)

               # if the salary range is less than 50000

               # calculate the raise salary

               # 5.5 percentage for all others

               else:

                   raiseSalary = eachSalary * (5.5/100.0)

               # calcaulating total raise salary

               totalRaise = totalRaise + raiseSalary

               #Display statement of pay raise for each faculty member

               # from the file

               print(" %-15.2f %-15.2f"%(eachSalary, eachSalary+raiseSalary))

               # Incrementing faculty count

               facultyCount = facultyCount + 1

   # Display statement for total amount of raises

   print("\n Total Amount of raises: " + str(totalRaise))

   # Display statement for average of the raises

   print(" Average of the raises: " + str(totalRaise/float(facultyCount)) + " \n")

      

#call main method

main()

Thank you. please like.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
PYTHON : Create a Email Address Parser (* Please do make comments*) Often times, you may...
PYTHON : Create a Email Address Parser (* Please do make comments*) Often times, you may be given a list of raw email addresses and be asked to generate meaningful information from such a list. This project involves parsing such a list and generating names and summary information from that list. The script, eparser.py, should: Open the file specified as the first argument to the script (see below) Read the file one line at a time (i.e., for line in...
Note: Do not use classes or any variables of type string to complete this assignment Write...
Note: Do not use classes or any variables of type string to complete this assignment Write a program that reads in a sequence of characters entered by the user and terminated by a period ('.'). Your program should allow the user to enter multiple lines of input by pressing the enter key at the end of each line. The program should print out a frequency table, sorted in decreasing order by number of occurences, listing each letter that ocurred along...
Write a Python 3 program called “parse.py” using the template for a Python program that we...
Write a Python 3 program called “parse.py” using the template for a Python program that we covered in this module. Note: Use this mod7.txt input file. Name your output file “output.txt”. Build your program using a main function and at least one other function. Give your input and output file names as command line arguments. Your program will read the input file, and will output the following information to the output file as well as printing it to the screen:...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT