Student Grade DA 5% HRA 10% PF 8%
class employee{ int code; string name; float basicsalary; public: employee(int c, string
Class student { private: .int enro; string name; string classname; float marks[5]; public: n, float b) : code(c), name(n), basicSalary(b) {} .friend float calsalary(Employee &e); void
void inputdetails(int enrollment, string stuname , string stuclass) { enro=enrollment; display() { cout-code-name-calsalary(*this) } }; float calsalary(employee &e) { return
name= stuname; classname=studclass; } void inputmarks() { cout-“5marks”; for(int e.basicSalary + (0.05 * e.basicSalary) + (0.10 * e.basicSalary) - (0.08 * e.basicSalary); }
i=0; i<5; i++) { cin>>marks[i]; } } void displaymarksheet() {float total=0; for (int i=0; i<5; int main() { Employee emp(101, "John Doe", 50000); emp.display(); return 0; }
i++) { total +=marks[i]; } } float per=(total/500)*100; string grade; if-grade; int main(){
STUDENT GETINFO
student student; student.inputdetails(101, “John” , “10”); student.inputmarks();
class student { .public: int marks; void getinfo(){ cout-entermarks; cin-marks; } };
student.displaymarksheet(); return 0; }
class sports { .public: int sportsmarks; void getsports() { cout- enterspormarks
cin-sportsmarks; } }; int main(){ statement s; s.getinfo(); s.getsports();
Shape Find area of circle – cmath s.display(); ret 0; }
class shape { public: double areacircle (double radius = 1.0) { return M_PI * radius
*radius; } double areasquare ( double side = 1.0){ return side*side; } double VECTOR CLASS
areadsquare(double length=1.0 , double width=1.0) { return length*width; } double #include <iostream>
areatriangle(double base = 1.0 , double height = 1.0) { return 0.5 * base * height; } };
using namespace std;
PRODUCT MANAGEMENT
class productmanagement{ private: int productid; string product_name; float price; int
class Vector {
qty; public: void Input_product( int id, string name, float price , int quantity) {
product_id=id; product_name=name; price=price; qty = quanitity; } void display() { int* arr;
cout-id-name-price-qtu-totalamount<<Calculate_amount() } float calculate_amount() {
int size;
return qty * price; } }; int main() { productmanagement product; product.input_product(
101,”laptop”,999.99,2); product.display(); return 0; } public:
Vector(int s) : size(s) { arr = new int[s]; }
N number of products
class product { static int count; public: product() { count++; } static int getcount() { ~Vector() { delete[] arr; }
return count; } }; int product::count =0; int main() { product p1,p2,p3; count-
product::getcount(); return 0;}
int& operator[](int index) { return arr[index]; }
TRAVEL FARE – string Vector operator+(const Vector& v) {
class travel { private: string T_code = “NULL”; int no_of_adults=0 , no_of_child=0 ,
distance=0; float totalfare=0; voide assignfare() { totalfare = no+of_adults * ( Distance Vector res(size);
>= 1000 ? 500 : (Distance >= 500 ? 300 : 200)); totalfare += no_of_chil * (totalfare / for (int i = 0; i < size; ++i) res[i] = arr[i] + v.arr[i];
no_of_adults) * 0.5; } public: void entertravel(){ cout-travelcode-noadult-nochild-dist;
return res;
assignfare(); } void showtravel() { cout-t_code-no_of_adults-no_of_child-distance-
totalfare } }; int main() { travel travel; travel.entertravel(); travel.showtravel(); return 0 ; } }
Vector operator-(const Vector& v) {
Vector res(size);
for (int i = 0; i < size; ++i) res[i] = arr[i] - v.arr[i];
VECTOR_2 SHAPE AREA
#include <iostream>
return res;
#include <cmath>
}
using namespace std;
Vector operator*(const Vector& v) {
Vector res(size);
class SHAPE {
for (int i = 0; i < size; ++i) res[i] = arr[i] * v.arr[i];
private:
return res;
double area;
}
Vector operator*(int scalar) {
public:
Vector res(size);
SHAPE() : area(0) {} // Default constructor
for (int i = 0; i < size; ++i) res[i] = arr[i] * scalar;
return res;
SHAPE(double a) : area(a) {} // Parameterized constructor
}
SHAPE(const SHAPE &s) : area(s.area) {} // Copy constructor
friend istream& operator>>(istream& in, Vector& v) {
void areaSquare(double side) { area = side * side; }
for (int i = 0; i < v.size; ++i) in >> v.arr[i];
void areaRectangle(double length, double width) { area = length * width; }
return in;
void areaCircle(double radius) { area = M_PI * radius * radius; }
}
friend ostream& operator<<(ostream& out, const Vector& v) {
double getArea() const { return area; } };
out << "(";
int main() {
for (int i = 0; i < v.size; ++i) {
SHAPE square, rectangle, circle; square.areaSquare(4);
out << v.arr[i];
rectangle.areaRectangle(5, 3); circle.areaCircle(2);
if (i < v.size - 1) out << ",";
cout << "Area of Square: " << square.getArea() << endl;
}
cout << "Area of Rectangle: " << rectangle.getArea() << endl;
out << ")";
cout << "Area of Circle: " << circle.getArea() << endl;
return out;
}
return 0;
};
}