Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

# universityTester.py import random from university import Instructor # Global constants RAISE 2 = 2 RAISE 5 = 5 RAISE 8 = 8 RAISE 1

# universityTester.py
import random
from university import Instructor
# Global constants
RAISE2=2
RAISE5=5
RAISE8=8
RAISE10=10
ADJ_PROF = 'Adjunct Professor'
ASSIS_PROF = 'Assistant Professor'
ASSOC_PROF = 'Associate Professor'
FULL_PROF = 'Full Professor'
ADJ_SAL =60000.00
ASSIS_SAL =80000.00
ASSOC_SAL =100000.00
FULL_SAL =120000.00
def main():
# Strings declaration
fName1= 'Smith'
fName2= 'Doe'
fName3= 'YourLastName'
# Function definitions
def getRandom():
"""
Generate a random integer number between 0 and 3 inclusive.
Returns:
int: Random integer between 0 and 3.
"""
return random.randint(0,3)
def startingSalary(num):
"""
Get starting salary based on the given number.
Parameters:
num (int): A number to determine starting salary.
Returns:
float: Starting salary based on the given number.
"""
if num ==0:
return ADJ_SAL
elif num ==1:
return ASSIS_SAL
elif num ==2:
return ASSOC_SAL
elif num ==3:
return FULL_SAL
else:
return 0.00
def classification(num):
"""
Get classification based on the given number.
Parameters:
num (int): A number to determine classification.
Returns:
str: Classification based on the given number.
"""
if num ==0:
return ADJ_PROF
elif num ==1:
return ASSIS_PROF
elif num ==2:
return ASSOC_PROF
elif num ==3:
return FULL_PROF
else:
return 'Unknown Professor'
def raiseSalary(num):
"""
Get raise percentage based on the given number.
Parameters:
num (int): A number to determine raise percentage.
Returns:
int: Raise percentage based on the given number.
"""
if num ==0:
return RAISE2
elif num ==1:
return RAISE5
elif num ==2:
return RAISE8
elif num ==3:
return RAISE10
else:
return 0.00
def printByAccessor(obj):
"""
Print rank, name, and salary of the given professor object.
Parameters:
obj (Instructor): The Instructor object to print details of.
"""
print(obj)
def goodBye():
"""Print last two lines to end the program."""
print("
This program was written by Dr. YourLastName.")
print("End of program.
")
# Step 1-5: Instantiate Instructor objects
num1= getRandom()
num2= getRandom()
classify1= classification(num1)
classify2= classification(num2)
salary1= startingSalary(num1)
salary2= startingSalary(num2)
person1= Instructor(classify1, fName1, salary1)
person2= Instructor(classify2, fName2, salary2)
person3= Instructor(classification(getRandom()), fName3, startingSalary(getRandom()))
# Step 6-8: Print details of Instructor objects
printByAccessor(person1)
printByAccessor(person2)
print(person3)
# Step 9-11: Raise salary for person1
num3= getRandom()
increase = raiseSalary(num3)
print(f"
Full Professor {fName1} will get an increase in salary by: {increase}%")
salary = person1.getSalary()
new_salary = salary *(1+ increase /100)
person1.setSalary(new_salary)
printByAccessor(person1)
# Step 12-14: Possibly change rank for person2
print("
Adjunct Professor Doe may or may not get a new title.")
classify3= classification(getRandom())
person2.setRank(classify3)
print(person2)
# Step 15-16: Create and print dictionaries
profRank ={'Num1': person1.getRank(), 'Num2': person2.getRank(), 'Num3': person3.getRank()}
print("
profRank:", profRank)
profName ={'Num1': fName1, 'Num2': fName2, 'Num3': fName3}
print("profName:", profName)
profSalary ={'Num1': person1.getSalary(), 'Num2': person2.getSalary(), 'Num3': person3.getSalary()}
print("profSalary:", profSalary)
# Step 17-18: Calculate and print total and average salaries
total_salary = profSalary['Num1']+ profSalary['Num2']+ profSalary['Num3']
print("
Total salary for professors: $", total_salary)
average_salary = total_salary /3
print("Average salary for professors: $", average_salary)
# Step 19: Print final lines
goodBye()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems 6th Asian Conference Aciids 2014 Bangkok Thailand April 7 9 2014 Proceedings Part I 9 2014 Proceedings Part 1 Lnai 8397

Authors: Ngoc-Thanh Nguyen ,Boonwat Attachoo ,Bogdan Trawinski ,Kulwadee Somboonviwat

2014th Edition

3319054759, 978-3319054759

More Books

Students also viewed these Databases questions

Question

Evaluate the following expressions to six-figure accuracy.

Answered: 1 week ago