UI23CS10_OOT(LAB3)
UI23CS10_OOT(LAB3)
UI23CS10_OOT(LAB3)
created.
CODE :
#include <iostream>
#include <string>
class BankAccount {
private:
string accountNumber;
double balance;
string customerName;
public:
accountNumber = accNum;
customerName = name;
balance = initialBalance;
totalAccounts++;
if (amount > 0) {
balance += amount;
cout << "Deposited " << amount << ". New balance: " << balance <<
endl;
} else {
}
}
if (amount > 0) {
balance -= amount;
cout << "Withdrew " << amount << ". New balance: " << balance
<< endl;
} else {
} else {
return totalAccounts;
};
int BankAccount::totalAccounts = 0;
int main() {
account1.deposit(500.0);
account1.withdrawal(200.0);
account2.deposit(1000.0);
account2.withdrawal(500.0);
return 0;
}
OUTPUT :
Question 2 :
CODE:
#include <iostream>
#include <string>
class Student {
private:
string name;
int rollNumber;
double marks;
public:
name = studentName;
rollNumber = studentRollNumber;
marks = studentMarks;
totalStudents++;
highestMarks = marks;
~Student() {
totalStudents--;
return totalStudents;
}
return highestMarks;
};
int Student::totalStudents = 0;
int main() {
student2.displayDetails();
student3.displayDetails();
return 0;
OUTPUT :
QUESTION 3:Define a class Car with attributes like brand, model, and price.
Implement a
CODE:
#include <iostream>
#include <string>
using namespace std;
class Car {
private:
string brand;
string model;
double price;
public:
brand = carBrand;
model = carModel;
price = carPrice;
~Car() {
cout << "Car object with brand " << brand << " and model " << model << "
is destroyed." << endl;
};
int main() {
car1.displayDetails();
car2.displayDetails();
return 0;
OUTPUT:
Question4 :
CODE :
#include <iostream>
class Rectangle {
private:
double length;
double breadth;
public:
Rectangle(double len, double br) {
length = len;
breadth = br;
};
int main() {
return 0;
OUTPUT :
Question 5 :
Define a class Book with attributes title and price. Implement a copy
CODE :
#include <iostream>
#include <string>
class Book {
private:
string title;
double price;
public:
title = bookTitle;
price = bookPrice;
title = other.title;
price = other.price;
};
int main() {
Book book1("C++ Programming", 29.99);
book1.displayDetails();
book2.displayDetails();
return 0;
OUTPUT:
Question 6:
perform the operations like adding, deleting items to the list and printing the
CODE :
#include <iostream>
#include <vector>
#include <algorithm>
class Item {
private:
int code;
double price;
public:
code = itemCode;
price = itemPrice;
return price;
cout << "Item Code: " << code << ", Price: " << price << endl;
};
class ShoppingList {
private:
vector<Item> items;
public:
items.push_back(newItem);
}
void deleteItem(int code) {
});
if (it != items.end()) {
items.erase(it);
} else {
cout << "Item with code " << code << " not found." << endl;
void printTotalValue() {
total += item.getPrice();
cout << "Total value of the order: $" << total << endl;
}
void printShoppingList() {
if (items.empty()) {
} else {
item.displayItem();
};
int main() {
ShoppingList list;
double price;
do {
switch (choice) {
case 1:
list.addItem(code, price);
break;
case 2:
list.deleteItem(code);
break;
case 3:
list.printShoppingList();
break;
case 4:
list.printTotalValue();
break;
case 5:
break;
default:
return 0;
OUTPUT:
Question 7:
Create a class Employee containing employee id, name, Basic, DA, TA, net
salary member. Write function to read data, print data, and compute net
CODE :
#include <iostream>
#include <string>
class Employee {
private:
int id;
string name;
public:
void readData() {
cin.ignore();
getline(cin, name);
void computeSalary() {
DA = 0.52 * basic;
void printData() {
};
int main() {
Employee emp;
emp.readData();
emp.computeSalary();
emp.printData();
return 0;
OUTPUT: