#Employee class creation
class Employee:
#constructor
def
__init__(self,empl_num,name,birth_month,birth_year,job_title,salary):
self.empl_num=empl_num
self.name=name
self.birth_Month=birth_month
self.birth_year=birth_year
self.job_title=job_title
self.salary=salary
#Function to calculate hourly
pay
def hourly_rate(self):
return
self.salary/2080
#function to calculate age
def age(self,month,year):
#
month=birth_Month-month
if
month<self.birth_Month:
age=year-(self.birth_year)-1
return age
else:
age=year-self.birth_year
return age
#function to calculate retirement status
def can_retire(self,m,y):
if(m<self.birth_Month):
age=(y-birth_yearr)-1
else:
age=y-self.birth_year
if(age>65):
return True
else:
return False
#to string method
def __str__(self):
template='{0.empl_num}
{0.name} {0.birth_Month} {0.birth_year} {0.job_title}
{0.salary}'
return
template.format(self)
#Main method or test method
def main():
#Instantiate an object
e1=Employee('E12345','Ashok',2,2000,'Lawyer',100000)
#Print using _str_
print(e1)
#display current age
print('Age=',e1.age(9,2018))
#Display current salary
print('Salary Per Hour=%.2f'%e1.hourly_rate())
#display current retirement status
print('Retirement status=',e1.can_retire(9,2018))
if __name__== "__main__":
main()
OUTPUT
E12345 Ashok 2 2000 Lawyer 100000
Age= 18
Salary Per Hour=48.08
Retirement status= False
Python In this assignment you are asked to enhance the #3 to define a class to...
python code? 1. Create a class called Person that has 4 attributes, the name, the age, the weight and the height [5 points] 2. Write 3 methods for this class with the following specifications. a. A constructor for the class which initializes the attributes [2.5 points] b. Displays information about the Person (attributes) [2.5 points] c. Takes a parameter Xage and returns true if the age of the person is older than Xage, false otherwise [5 points] 3. Create another...
C++ Your solution will consist of the following four files: HeartRates.h (class specification file) HeartRates.cpp (class implementation file) 200_assign4.cpp (application program) 200_assign4.pdf (sample runs) For your fourth programming assignment you will be writing the following C++ program: The formula for calculating your maximum heart rate in beats per minute is 220 minus your age in years. Your target heart rate is a range that is 50-85% of your maximum heart rate. Create a class called HeartRates. The class attributes should...
reate a class called Person with the following attributes: name - A string representing the person's name age - An int representing the person's age in years As well as appropriate __init__ and __str__ methods, include the following methods: get_name(self) - returns the name of the person get_age(self) - returns the age of the person set_name(self, new_name) - sets the name for the person set_age(self, new_age) - sets the age for the person is_older_than(self, other) - returns True if this...
My Java code from last assignment: Previous Java code: public static void main(String args[]) { // While loop set-up boolean flag = true; while (flag) { Scanner sc = new Scanner(System.in); // Ask user to enter employee number System.out.print("Enter employee number: "); int employee_number = sc.nextInt(); // Ask user to enter last name System.out.print("Enter employee last name: "); String last_name = sc.next(); // Ask user to enter number of hours worked System.out.print("Enter number of hours worked: "); int hours_worked =...
My Java code from last assignment: Previous Java code: public static void main(String args[]) { // While loop set-up boolean flag = true; while (flag) { Scanner sc = new Scanner(System.in); // Ask user to enter employee number System.out.print("Enter employee number: "); int employee_number = sc.nextInt(); // Ask user to enter last name System.out.print("Enter employee last name: "); String last_name = sc.next(); // Ask user to enter number of hours worked System.out.print("Enter number of hours worked: "); int hours_worked =...
Python 3 Question Please keep the code introductory friendly and include comments. Many thanks. Prompt: The owners of the Annan Supermarket would like to have a program that computes the weekly gross pay of their employees. The user will enter an employee’s first name, last name, the hourly rate of pay, and the number of hours worked for the week. In addition, Annan Supermarkets would like the program to compute the employee’s net pay and overtime pay. Overtime hours, any...
Tasks A. (20 po ints) In Lab 6, you defined and implemented a class called Date. You will make some modific ation to the Date class so that it mccts the folowing specific ations: The Date class consists of three private member variables: Member Variable year month day Description An int variable that hokls the value of a year. An int variable that hokds the value of a month An int variable that hokis the value of a day. The...
Create an abstract class “Appointment” that represents an event on a calendar. The “Appointment” class will have four instance variables: • An instance variable called “year” which will be of type int • An instance variable called “month” which will be of type int • An instance variable called “day” which will be of type int • An instance variable called “description” which will be of type String The “Appointment” class must also implement the following methods: • A getter...
could you solve this in C++ please 2. (25 marks) Define a class called "House", that represents the information of a house. A House is defined with these attributes: age (int), type (string) (Detached, Semi-Attached, Attached), rooms (int) and cost (double). Functions of the House class must perform the following operations: • Return the house age • Modify the house age • Return the house type • Return the number of rooms • A function called estimate Price() that returns...
Writing 3 Java Classes for Student registration /** * A class which maintains basic information about an academic course. */ public class Course { /** * Attributes. */ private String code; private String title; private String dept; // name of department offering the course private int credits; /** * Constructor. */ public Course(String code, String title, int credits) { // TODO : initialize instance variables, use the static method defined in // Registrar to initialize the dept name variable...