EX NO 8A: OOPS LAB - CLASS TEMPLATE
EX NO 8A: Class Templates
1.
Generic Bank Account System ( RNO – 1 TO
5)
Steps:
- Define a class template Account<T>
- Declare data members: balance (T), account holder name
- Initialize balance using constructor
- Create function deposit(T
amount)
- Check if amount > 0
- Add amount to balance
- Create function withdraw(T
amount)
- Check if amount <= balance
- Deduct amount, else display “Insufficient Balance”
- Create function to display account details
- In main(), create multiple objects with different data
types
- Perform multiple transactions
- Display updated balance after each transaction
2.
Student Management System ( RNO – 6 TO 10)
Steps:
- Define class template with parameters <T1, T2, T3>
- Declare roll number, name, and marks
- Create constructor to initialize values
- Create function to calculate grade based on marks
- Create function to display student details with grade
- Allow input for multiple students using loop
- Store and process each student record
- Display all student records
3.
Shopping Cart System ( RNO – 11 TO 15)
Steps:
- Define class template <T1,
T2> for price and quantity
- Declare item name, price, quantity
- Create function to input multiple items
- Calculate total cost for each item
- Maintain grand total for all items
- Apply discount if total exceeds a limit
- Display item-wise bill and final amount
4.
Generic Stack Implementation ( RNO – 16 TO 20)
Steps:
- Define class template <T>
- Declare array, top, and max size
- Initialize stack using constructor
- Create push()
- Check overflow condition
- Create pop()
- Check underflow condition
- Create peek() to view top element
- Use menu-driven approach (push/pop/display)
- Repeat until user exits
5.
Employee Payroll System ( RNO – 21 TO 25)
Steps:
- Define class template <T> for salary
- Declare employee ID, name, basic salary, bonus
- Create function to calculate gross salary
- Deduct tax based on salary range
- Compute net salary
- Display payroll details
- Handle multiple employees using loop
6.
Library Management System ( RNO – 26 TO 30)
Steps:
- Define class template <T1,
T2, T3>
- Declare book ID, title, price
- Add availability status (issued/not issued)
- Create function to issue book
- Create function to return book
- Display available books
- Use menu-driven system
7.
Matrix Addition System ( RNO – 31 TO 40)
Steps:
- Define class template <T>
- Declare matrices and size variables
- Input matrix elements using loops
- Check if matrix dimensions match
- Perform matrix addition
- Display resultant matrix
- Repeat for different data types
8.
Generic Sorting System ( RNO – 41 TO 45)
Steps:
- Define class template <T>
- Declare array and size
- Input elements
- Implement sorting algorithm (bubble/selection sort)
- Compare elements using template type
- Display sorted array
- Allow user to repeat sorting
9.
Result Processing System ( RNO – 46 TO 55)
Steps:
- Define class template <T>
- Declare marks for multiple subjects
- Input marks using loop
- Calculate total and average
- Assign grade using conditions
- Display result summary
- Handle multiple students
10.
Queue Management System ( RNO – 56 TO 61)
Steps:
- Define class template <T>
- Declare array, front, rear, size
- Initialize queue
- Create enqueue()
- Check overflow
- Create dequeue()
- Check underflow
- Create display()
- Implement menu-driven system
- Perform operations repeatedly
Comments
Post a Comment