A Dvace Oop Lab Report Solved 2 4th Cs
A Dvace Oop Lab Report Solved 2 4th Cs
Submitted By:
Hamza Nazir
(2872)
Submitted To:
DATE:10/05/2023
Task 1:
Write a python program to create a Vehicle class with max_speed and mileage instance
attributes.
4. Class Inheritance
Given:
Create a Bus class that inherits from the Vehicle class. Give the capacity argument
Define a class attribute”color” with a default value white. I.e., Every Vehicle should be
white.
6. Class Inheritance
Given:
Create a Bus child class that inherits from the Vehicle class. The default fare charge of
any vehicle is seating capacity * 100. If Vehicle is Bus instance, we need to add an extra
10% on full fare as a maintenance charge. So total fare for bus instance will become
Note: The bus seating capacity is 50. so the final fare amount should be 5500. You need
Code:
class vechile
int seating;
void set_seating_anyVechicle(int seating)
{
class Bus
void Busseating_capacity()
{
seating=50;
}
void fare()
{
int a=((seating*100)/50)*100;
System.out.println("bus fare charges "+(a+(seating*100)));
}
Pet interface
}
}
Output
Task 2:
Objective
Q1: Write a Python class Employee with attributes like emp_id, emp_name,
emp_salary, and emp_department and methods like calculate_emp_salary,
emp_assign_department, and print_employee_details.
Sample Employee Data:
"ADAMS", "E7876", 50000, "ACCOUNTING"
"JONES", "E7499", 45000, "RESEARCH"
"MARTIN", "E7900", 50000, "SALES"
"SMITH", "E7698", 55000, "OPERATIONS"
Use 'assign_department' method to change the department of an employee.
Use 'print_employee_details' method to print the details of an employee.
Use 'calculate_emp_salary' method takes two arguments: salary and
hours_worked, which is the number of hours worked by the employee. If the
Code:
class Employee
void print_employee_details()
{
// "ADAMS", "E7876", 50000, "ACCOUNTING"
System.out.println("'"+emp_name+"'"+" "+emp_id+" "+"'"+emp_salary+"'"+" "+emp_department+"'");
}
}
Output
Task 3:
Objective
Q2: Write a Python class BankAccount with attributes like account_number,
balance, date_of_opening and customer_name, and methods like deposit,
withdraw,
Code:
class BankAccount
Output