Krisa-oops_journal
Krisa-oops_journal
Q-1 Create a class 'Bank' comprises of data like bank_id, bank_name, brance_name and
create another class 'Account' which holds data like ac_no, ac_name, ac_type
(saving/current), and balance. Create another class 'Transaction' which holds the
functions to perform following operations:
Ans:-
#include <iostream>
#include <vector>
#include <string>
using namespace std;
// Define a struct to represent a bank account
struct Account {
int number; // account number
string name; // account holder's name
string type; // type of account (saving or current)
double balance; // initial balance
};
1
ROLL NO :- 2481035 Lakkad Krisa Shaileshbhai SYBCA DIV - E
return 0;
2
ROLL NO :- 2481035 Lakkad Krisa Shaileshbhai SYBCA DIV - E
Output:-
3
ROLL NO :- 2481035 Lakkad Krisa Shaileshbhai SYBCA DIV - E
Q-2 Create a class Str which stores a string value. Overload +, == for concatenation and
comparison operation respectively.
Ans:-
#include <iostream>
#include <string>
using namespace std;
class Str {
public:
string str;
Str(string s) : str(s) {}
Str operator+(Str other) {
return Str(str + other.str);
}
bool operator==(Str other) {
Output :-
4
ROLL NO :- 2481035 Lakkad Krisa Shaileshbhai SYBCA DIV - E
Q-3 Create class using multilevel inheritance of student list 1st class contain roll no and
name of student 2nd class contain marks of three subject 3rd class contain total and
percentage Input data of at least 5 student and display all the information in proper
format.
Ans:-
#include <iostream>
#include <string>
class Student {
public:
int rollNo;
string name;
int marks1, marks2, marks3;
int total;
float percentage;
void displayStudentInfo() {
cout << "Roll No: " << rollNo << endl;
cout << "Name: " << name << endl;
cout << "OOPS&DS: " << marks1 << endl;
cout << "DBHUP: " << marks2 << endl;
cout << "CYBER SECURITY: " << marks3 << endl;
cout << "Total: " << total << endl;
cout << "Percentage: " << percentage << "%" << endl;
}
};
int main() {
cout << "NAME: LAKKAD KRISA SHAILESHBHAI\n";
cout << "CLASS : SYBCA - E\n";
cout << "Roll No : 2481035\n";
cout << "\n";
Student students[2];
5
ROLL NO :- 2481035 Lakkad Krisa Shaileshbhai SYBCA DIV - E
Output :-
6
ROLL NO :- 2481035 Lakkad Krisa Shaileshbhai SYBCA DIV - E
Q-4 Create a book class (bookid, bookname, year, publication) & student class (rollno,
name, year, books). Display list of books borrowed by student from library.
Ans:-
#include <iostream>
#include <string>
#include <vector>
class Book {
public:
int bookId;
string bookName;
int year;
string publication;
void displayBookInfo() {
cout << "Book ID: " << bookId << endl;
cout << "Book Name: " << bookName << endl;
cout << "Year: " << year << endl;
cout << "Publication: " << publication << endl;
}
};
class Student {
public:
int rollNo;
string name;
int year;
vector<Book> borrowedBooks;
7
ROLL NO :- 2481035 Lakkad Krisa Shaileshbhai SYBCA DIV - E
void displayStudentInfo() {
cout << "Roll No: " << rollNo << endl;
cout << "Name: " << name << endl;
cout << "Year: " << year << endl;
}
void displayBorrowedBooks() {
if (borrowedBooks.empty()) {
cout << "No books borrowed." << endl;
} else {
cout << "Borrowed Books:" << endl;
for (Book book : borrowedBooks) {
book.displayBookInfo();
cout << endl;
}
}
}
};
int main() {
// Create books
Book book1(1, "J2L-OOPS", 2020, "Pub1");
Book book2(2, "STATASTICS", 2019, "Pub2");
Book book3(3, "EXPERT IN PYTHON", 2018, "Pub3");
// Create students
Student student1(1, "Krisa", 2022);
Student student2(2, "Ritika", 2021);
// Borrow books
student1.borrowBook(book1);
student1.borrowBook(book2);
student2.borrowBook(book3);
student2.displayStudentInfo();
student2.displayBorrowedBooks();
8
ROLL NO :- 2481035 Lakkad Krisa Shaileshbhai SYBCA DIV - E
return 0;
}
Output :-
9
ROLL NO :- 2481035 Lakkad Krisa Shaileshbhai SYBCA DIV - E
Q-5 Create an event class, create dynamic objects of event class and release the memory
of the created object before program terminates.
Ans:-
#include <iostream>
#include <string>
class Event {
public:
string eventName;
string eventDate;
int main() {
cout << "NAME: LAKKAD KRISA SHAILESHBHAI\n";
cout << "CLASS : SYBCA - E\n";
cout << "Roll No : 2481035\n";
cout << "\n";
10
ROLL NO :- 2481035 Lakkad Krisa Shaileshbhai SYBCA DIV - E
return 0;
}
Output:-
11
ROLL NO :- 2481035 Lakkad Krisa Shaileshbhai SYBCA DIV - E
Ans:-
#include <iostream>
class Stack {
private:
int arr[10];
int top;
public:
Stack() {
top = -1;
}
int pop() {
if (top >= 0) {
return arr[top--];
} else {
cout << "Stack is empty." << endl;
return -1;
}
}
void display() {
for (int i = 0; i <= top; i++) {
cout << arr[i] << " ";
}
cout << endl;
}
};
int main() {
12
ROLL NO :- 2481035 Lakkad Krisa Shaileshbhai SYBCA DIV - E
Stack stack;
while (true) {
cout << "1. Push" << endl;
cout << "2. Pop" << endl;
cout << "3. Display" << endl;
cout << "4. Exit" << endl;
int choice;
cin >> choice;
switch (choice) {
case 1: {
int value;
cout << "Enter value: ";
cin >> value;
stack.push(value);
break;
}
case 2: {
int value = stack.pop();
if (value != -1) {
cout << "Popped value: " << value << endl;
}
break;
}
case 3: {
stack.display();
break;
}
case 4: {
return 0;
}
default: {
cout << "Invalid choice." << endl;
}
}
}
return 0;
}
13
ROLL NO :- 2481035 Lakkad Krisa Shaileshbhai SYBCA DIV - E
Output :-
14
ROLL NO :- 2481035 Lakkad Krisa Shaileshbhai SYBCA DIV - E
Ans:-
#include <iostream>
#include <stack>
#include <string>
while (!s.empty()) {
postfix += s.top();
s.pop();
}
return postfix;
}
int main() {
15
ROLL NO :- 2481035 Lakkad Krisa Shaileshbhai SYBCA DIV - E
string infix;
cout << "Enter infix expression: ";
cin >> infix;
return 0;
}
Output :-
16
ROLL NO :- 2481035 Lakkad Krisa Shaileshbhai SYBCA DIV - E
Ans:-
#include <iostream>
using namespace std;
class Queue {
private:
int queue[10]; // array to store queue elements
int front; // index of front element
int rear; // index of rear element
int count; // number of elements in queue
public:
Queue() {
front = 0;
rear = 0;
count = 0;
}
17
ROLL NO :- 2481035 Lakkad Krisa Shaileshbhai SYBCA DIV - E
i = (i + 1) % 10;
}
cout << endl;
}
}
};
int main() {
Queue q;
return 0;
}
Output:-
18