-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCode.cpp
More file actions
74 lines (55 loc) · 1.6 KB
/
Copy pathCode.cpp
File metadata and controls
74 lines (55 loc) · 1.6 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
#include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
string product[4]; //Stores name of all products
int cost[4]; //Stores cost of all products
int gst[4]; //Stores gst amount of all products
int qt[4]; //Stores quantity of all products
product[0] = "Leather wallet";
product[1] = "Umbrella";
product[2] = "Cigarette";
product[3] = "Honey";
cost[0] = 1100;
cost[1] = 900;
cost[2] = 200;
cost[3] = 100;
gst[0] = 18;
gst[1] = 12;
gst[2] = 28;
gst[3] = 0;
qt[0] = 1;
qt[1] = 4;
qt[2] = 3;
qt[3] = 2;
int max_gst_index;
int max_gst = INT_MIN;
//Function to calculate maximum gst amount product
for(int i=0; i<4; i++)
{
int val = (gst[i]*cost[i])/100; //gst amount paid for i-th Item
if(val>max_gst)
{
max_gst = val;
max_gst_index = i;
}
}
cout << "Item with maximum gst is " << product[max_gst_index] << "." << endl;
int total_amount = 0;
//Function to calculate total amount paid by the user
for(int i=0; i<4; i++)
{
int amount = cost[i]; //current amount
int temp = cost[i]; //temperary variable to store the value of cost of the current product
if(temp>=500)
{
amount = amount - (5*temp)/100;
}
amount = amount + (gst[i]*temp)/100;
total_amount += amount*qt[i];
}
cout << "The total amount the user needs to pay for all the products is " << total_amount << "." << endl;
return 0;
//Item with maximum gst is Leather wallet.
//The total amount the user needs to pay for all the products is 6063.
}