This repository was archived by the owner on Sep 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInventory.c
128 lines (71 loc) · 2.33 KB
/
Inventory.c
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
//Author: Nathaniel Mugenyi
//Date: 26.06.2024
//Title: Inventory Management System
//Description: Allows you to manage a small inventory, add items, display items, update items, and calulate inventory value
#include <stdio.h>
#include <stdlib.h>
int main () {
//Items
char *shelf[5] ={"Bananas","Tomatoes","Carrots","Onions","Garlic"};
int qty[5] = {0,0,0,0,0};//list for quantities per item
int uprice[5] = {300,200,400,100,1000};//list for prices per item
//Instrucitions
int select,item, entry; //selectors
while (select != 5){
printf("\n____Wandegeya Grocery Stall____\n");
printf("Select by entering a number on a listed item.\n");
printf("1. Add Item\n");
printf("2. Display Inventory\n");
printf("3. Update Item\n");
printf("4. Calculate total Value\n");
printf("5. Exit\n");
scanf("%d",&select);
//Add Item
if (select == 1){
printf("Select an item\n");
for (int i = 0; i <= 4; i++){
int ln = i+1;//list Number
printf("%d. %s Qty: %d\n",ln,shelf[i],qty[i]);
}
scanf("\n%d",&item);
qty[item-1] ++;
printf("\nItem Added Successfully\n");
printf("Item:%s New Qty:%d",shelf[item-1],qty[item-1]);
}
//Display Inventory
else if (select == 2) {
for (int i = 0; i <= 4; i++){
int ln = i+1;//list Number
printf("%d. %s Qty: %d Unit Price: %d\n",ln,shelf[i],qty[i],uprice[i]);
}
}
//Update Item
if (select == 3){
printf("Select an item\n");
for (int i = 0; i <= 4; i++){
int ln = i+1;//list Number
printf("%d. %s Qty: %d\n",ln,shelf[i],qty[i]);
}
scanf("\n%d",&item);
printf("What is the new Qty? ");
scanf("%d",&entry);
qty[item-1] = entry;
printf("\nItem Qty Changed Successfully\n");
printf("Item:%s New Qty:%d",shelf[item-1],qty[item-1]);
}
//Calculate Total Value
if (select == 4){
int itemc;//item cost
int total;//total inventory value
for(int uc = 0; uc <= 4; uc++){
itemc = itemc + (qty[uc] * uprice[uc]);
}
printf("The total Cost of all inventory Items is: %d UGX", itemc);
itemc = 0; //reset
}
//Exit
else if (select == 5){
exit(0);
}
}
}