Class of Shop to tell the Price and itemId of a item.
#include <iostream>
using namespace std;
class shop
{
private:
int itemId[100];
int itemPrice[100];
public:
int counter = 1;
void setPrice();
void displayPrice();
};
void shop::setPrice()
{
cout << "Enter the itemId of item " << counter << " ";
cin >> itemId[counter];
cout << "Enter the price of the item " << counter << " ";
cin >> itemPrice[counter];
counter++;
}
void shop::displayPrice()
{
for (int i = 1; i < counter; i++)
{
cout << "The Price of item " << itemId[i] << " is " << itemPrice[i] << endl;
}
}
int main()
{
int x;
cout << "For how many Item you want to know the Price ";
cin >> x;
shop Apurti;
for (int j = 1; j <= x; j++)
{
Apurti.setPrice();
Apurti.displayPrice();
}
return 0;
}
Comments
Post a Comment