Sen 306 Practical Assignment
Sen 306 Practical Assignment
Sen 306 Practical Assignment
EMPLOYEE
- emp_id: int
- emp_name: string
- emp_address: string
- emp_mobile: string
+ ADD(): void
+ DELETE(): void
+ EDIT(): void
b. Write an OOP program in any language of your choice to implement the Class
SOLUTION
class Employee:
self.emp_id = emp_id
self.emp_name = emp_name
self.emp_address = emp_address
self.emp_mobile = emp_mobile
def display_info(self):
print(f"Name: {self.emp_name}")
print(f"Address: {self.emp_address}")
print(f"Mobile: {self.emp_mobile}")
print()
employee_list.append(new_employee)
global employee_list
if employee.emp_id == emp_id_to_edit:
employee.emp_name = new_name
employee.emp_address = new_address
employee.emp_mobile = new_mobile
# Example Usage
employee_list = []
employee.display_info()
# Deleting an employee
employee2.delete_employee(102)
employee.display_info()
# Editing an employee
employee.display_info()
c. Write a program to create an array object of the class table to store all the data items shown in
the table.
SOLUTION
class Employee:
self.emp_id = emp_id
self.emp_name = emp_name
self.emp_address = emp_address
self.emp_mobile = emp_mobile
def display_info(self):
print(f"Name: {self.emp_name}")
print(f"Address: {self.emp_address}")
print(f"Mobile: {self.emp_mobile}")
print()
employee_array = [
employee.display_info()
2. An application that determines whether any of several department store customers has
exceeded his or her credit limit on a charge account is to be developed. For each customer, the
a. Account number
The program should input all these facts as integers, calculate the new balance as:
Display the new balance and determine whether the new balance exceeds the customer’s credit
limit. For those customers whose credit limit is exceeded, the program should display the
c. Implement the credit limit determination module in any language of your choice
SOLUTION
(Start)
v
[Input Facts]
[Display Results]
(End)
Customer Program
| |
| Input |
|-----------> |
| |
| Calculate |
| <----------- |
| |
| Display |
| <-----------|
| |
c. Implement the credit limit determination module in any language of your choice
Python
class Customer:
self.account_number = account_number
self.beginning_balance = beginning_balance
self.charges = charges
self.credits = credits
self.credit_limit = credit_limit
def calculate_new_balance(self):
def check_credit_limit(self):
new_balance = self.calculate_new_balance()
else:
# Example usage:
customer_data = {
"account_number": 1234,
"beginning_balance": 1000,
"charges": 500,
"credits": 300,
"credit_limit": 1200
}
customer = Customer(**customer_data)
result = customer.check_credit_limit()
print(result)