Q1.
Create an employee object with properties such as name, department, currentSalary, leavesCount etc.
Now add methods for this object which performs certain tasks such as,
- let’s say an employee is allowed 30 leaves per year, make a function to decrease leavesCount when an employee takes a leave.
- Employee has a currentSalary, let’s say he/she is promoted then make a function to increase the salary by certain percent.
Q2. (Adv.)
- Create a cricketer object with properties such as name, team, role, matches, runs, wickets etc.
- Then create method to calculate the average runs scored per match for this object such as, let’s say an employee has played 30 matches and has scored 450 runs so his average is 15 (runs/matches = 450/30).
- Create separate methods to increase number of matches, runs & wickets as well.
Expected Output:
Name: Cricketer123
Team: India
Role: AllRounder
Matches played: 124
Runs scored: 890
Average: 7.18
Wickets taken: 178Q3. (Adv.)
Create a car object with properties such as modelName, type, company, fuelType, fuelTankCapacity, maxPower, mileage, seatingCapacity etc.
Now add methods for this object which performs certain tasks such as,
- Functionality to change the fuel type of the car.
- Functionality to increase engine power (maxPower) of the car.
- Functionality to update mileage of the car.
Expected Output:
i20 Sportz Turbo
Brand: Hyundai
Car Type: Hatchback
Fuel Type: Petrol
Fuel Tank Capacity: 40
Max Power in HP(HorsePower): 90
Mileage in KMPL(KiloMeter per Litre): 20
Seating Capacity: 5