#include<iostream>
using namespace std;
class Item
{
private:
int Sr_No;
char iname[20];
int price;
public:
void input()
{
cout << "Enter Item Id: ";
cin >> Sr_No;
cout << "Enter Item Name: ";
cin >> iname;
cout << "Enter Item Price: ";
cin >> price;
}
void display()
{
cout << Sr_No << " " << iname << " " << price << endl;
}
int getPrice() // Getter function to access private price variable
{
return price;
}
};
class User
{
private:
int bill;
public:
User() : bill(0) {} // Initialize bill to 0
void getdata(Item& i1, Item& i2)
{
bill = i1.getPrice() + i2.getPrice(); // Sum prices of both items
cout << "Total bill: " << bill << endl;
}
};
int main()
{
Item i1, i2;
User u;
i1.input();
i2.input();
cout << "-------------------------------------" << endl;
cout << "Sr.No" << " " << "Item Name" << " " << "Price" << endl;
cout << "-------------------------------------" << endl;
i1.display();
i2.display();
cout << "-------------------------------------" << endl;
u.getdata(i1, i2); // Passing both items to calculate the total bill
return 0;
}