-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproduct.cpp
83 lines (75 loc) · 1.64 KB
/
product.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//product name, quantity, code, price, instock, outstock;
#include <iostream>
using namespace std;
class product
{
private:
char name[100];
long code;
double price;
int stocks=0, newstk;
int nitems;
public:
void accept();
void display();
void instock();
void outstock();
};
void product::accept()
{
cout << "\nEnter product name: ";
cin >> name;
cout << "Enter product code: ";
cin >> code;
cout << "Enter product price: Rs. ";
cin >> price;
}
void product::display()
{
cout << "\nProduct Name : " << name;
cout << "\nCode : " << code;
cout << "\nPrice : Rs. " << price;
}
void product::instock()
{
// stocks=0;
cout << "Enter number of new stocks: ";
cin >> newstk;
stocks += newstk;
}
void product::outstock()
{
char ch;
display();
cout << "\nEnter no. of items required for customer : ";
cin >> nitems;
if (stocks >= nitems)
{
stocks -= nitems;
cout << "In stock !";
cout << "\nNo. of products left: " << stocks << endl;
}
else
{
cout << "\nOut of stock!" << endl;
cout << "\nNo. of products left: " << stocks << endl;
}
cout << "\n---------------------------------------------------------------------\n";
cout << "\nDo you want to continue for next customer (Press Y -YES or N -NO): ";
cin >> ch;
if (ch == 'Y' || ch == 'y')
{
instock();
outstock();
}
else
exit(0);
}
int main()
{
product p;
p.accept();
p.instock();
p.outstock();
return 0;
}