-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOpps3.cpp
63 lines (55 loc) · 1.06 KB
/
Opps3.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <iostream>
using namespace std;
class Shop
{
int itemId[100];
int itemPrice[100];
int counter;
public:
void initCounter(void) { counter = 0; }
void setPrice(void);
void displayPrice(void);
};
void Shop ::setPrice(void)
{
cout << "Enter Id of your item no " << counter + 1 << endl;
cin >> itemId[counter];
cout << "Enter Price of your item" << endl;
cin >> itemPrice[counter];
counter++;
}
void Shop ::displayPrice(void)
{
for (int i = 0; i < counter; i++)
{
cout << "The Price of item with Id " << itemId[i] << " is " << itemPrice[i] << endl;
}
}
int main()
{
Shop dukaan;
dukaan.initCounter();
dukaan.setPrice();
dukaan.setPrice();
dukaan.setPrice();
dukaan.displayPrice();
return 0;
}
/*
Output :
Enter Id of your item no 1
4
Enter Price of your item
40
Enter Id of your item no 2
5
Enter Price of your item
50
Enter Id of your item no 3
6
Enter Price of your item
60
The Price of item with Id 4 is 40
The Price of item with Id 5 is 50
The Price of item with Id 6 is 60
*/