-
Notifications
You must be signed in to change notification settings - Fork 0
/
transaction.c
73 lines (66 loc) · 1.49 KB
/
transaction.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
#include<stdio.h>
char inputTransactionType(char *msg,int i)
{
char type;
printf(msg,i);
scanf(" %c",&type);
switch (type)
{
case 'W':
type='W';
break;
case 'w':
type='W';
break;
case 'D':
type='D';
break;
case 'd':
type='D';
break;
default:
printf("Invalid Transaction Type!!!\n");
type='X';
break;
}
return type;
}
int main(void)
{
int i,j;
float totalWithdraw,maxWithdraw,totalDeposit,maxdeposit,array[5][4],maxWithdrawer[8],maxDepositer[8];
for (i=0;i<5;i++)
{
printf("Enter the %i Customer Acc Num : ",i+1);
scanf("%i",&array[i][0]);
printf("Enter the %i Customer Name : ",i+1);
scanf("%s",&array[i][1]);
while ((array[i][2] = inputTransactionType("Enter the %i Customer Transaction Type : ",i+1))=='X');
printf("Enter the %i Customer Transaction Amount : ",i+1);
scanf("%f",&array[i][3]);
printf("\n ------------------------------------------------------------------------------------------ \n");
}
for (i=0;i<5;i++)
{
if (array[i][2] == 'W')
{
totalWithdraw += array[i][3];
if (maxWithdraw<array[i][3])
{
*maxWithdrawer = array[i][1];
}
}
else if (array[i][2] == 'D')
{
totalDeposit += array[i][3];
if (maxdeposit<array[i][3])
{
*maxDepositer = array[i][1];
}
}
}
printf("Total Deposit Amount : %.2f\n",totalDeposit);
printf("Total Withdraw Amount : %.2f\n",totalWithdraw);
printf("max depositer : %s\n",maxDepositer);
printf("max withdraw : %s\n",maxWithdrawer);
}