-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvendingmachine.cpp
More file actions
97 lines (77 loc) · 1.54 KB
/
vendingmachine.cpp
File metadata and controls
97 lines (77 loc) · 1.54 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
#include <iostream>
using namespace std;
int main ()
{
int vendingMachine;
int items;
//do {
selection:
cout<<"Please select from the following items"<<endl;
cout<<"Item 1 : Chips - 50$"<<endl;
cout<<"Item 2 : Biscuits - 20$"<<endl;
cout<<"Item 3 : Coke - 60$"<<endl;
cout<<"Item 4 : Chocolate - 100$"<<endl;
cout<<"Item 5 : Coffee - 70$"<<endl;
cout<<"\nENTER THE ITEM NUMBER YOU WANT TO PURCHASE :"<<endl;
cin>>items;
switch (items)
{
case 1:
cout<<"You added chips to your cart"<<endl;
break;
case 2:
cout<<"You added Biscuits to your cart"<<endl;
break;
case 3:
cout<<"You added Coke to your cart"<<endl;
break;
case 4:
cout<<"You added Chocolate to your cart"<<endl;
break;
case 5:
cout<<"You added Coffee to your cart"<<endl;
break;
default:
cout<<"You entered wrong input"<<endl;
break;
}
int quantity;
int price;
int totalprice;
cout<<"Enter Quantity"<<endl;
cin>>quantity;
if (items==1) {
price=50*quantity;
cout<<"Your total price is "<<price<<"$"<<endl;
}
else if(items==2){
price=20*quantity;
cout<<"Your total price is "<<price<<"$"<<endl;
}
else if(items==3){
price=60*quantity;
cout<<"Your total price is "<<price<<"$"<<endl;
}
else if(items==4){
price=100*quantity;
cout<<"Your total price is "<<price<<"$"<<endl;
}
else if(items==5){
price=70*quantity;
cout<<"Your total price is "<<price<<"$"<<endl;
}
int input;
cout <<"\nDo you want to shop more?\nPress 1 for yes and 0 to dismiss"<<endl;
cin>>input;
if (input==1)
{
goto selection;
}
else if(input==0)
{
cout<<"Thank you for Shopping"<<endl;
//return 0;
}
//while (quantity=10);
return 0;
}