forked from VivekDubey9/Competitive-Programming-Algos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Billing systems
68 lines (52 loc) · 1.36 KB
/
Billing systems
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
#include<iostream>
using namespace std;
double getUnitprice(int itemCode);
int main(){
double invoice[10][4];
int i=0; char more; char date[100];
cout << "\n\n********* Here are the Item prices for your information********** \n\nItem code\tUnitPrice\n\n1\t100\n2\t200\n3\t300\nInvalidCode\t0\n\n";
cout << "Enter the date: ";
cin >> date;
do {
cout << "\n\nItem code: ";
cin >> invoice[i][0];
cout << "Quantity : ";
cin >> invoice[i][1];
invoice[i][2] = getUnitprice(invoice[i][0]);
invoice[i][3] = invoice[i][1] * invoice[i][2];
cout << "Do you have any other items to be entered next (y/n) ? ";
cin >> more;
i++;
} while(more == 'y');
cout << "\n\n-----------------------------\n\n";
cout << "Date : " << date << "\n\n";
cout << "ItemCode|Quantity|UnitPrice|TotalPrice\n\n";
int tot=0;
for(int k=0; k<i; k++)
{
for(int l=0; l<4; l++)
{
cout << invoice[k][l] << "\t";
}
cout << endl;
tot = tot + invoice[k][3];
}
cout << "\n\nTotal : " << tot;
cout << "\n\n-----------------------------\n\n\n";
return 0;
}
double getUnitprice(int itemCode){
double price;
switch (itemCode)
{
case 1: price = 100;
break;
case 2: price = 200;
break;
case 3: price = 300;
break;
default: price = 0;
break;
}
return price;
}