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
|
#include<stdio.h>
void deposite();
void withdraw();
char line[256]; // line used for input
int main()
{
int choice, a;
float money,m;
printf("Student ID : TATA_12345\n");
printf("NAME : RATAN TATA\n");
printf("(1) DEPOSITE MONEY\n");
printf("(2) WITHDRAW MONEY\n");
printf("(3) FIND THE ACCOUNT BALANCE\n");
printf("Enter your choice : ");
fgets(line, sizeof(line), stdin);
sscanf(line, "%d", &choice);
switch (choice)
{
case 1:
deposite(); /*to deposite money*/
break;
case 2:
withdraw(); /*to withdraw money*/
break;
case 3: /*to see the balance*/
printf("\nThis facility is not currently available\n");
break;
default: /*if choice is not valid*/
printf("ERROR// PLEASE TRY AGAIN");
return 0;
}
printf("Press any key to continue...");
getchar();
return 0;
}
void deposite()
{
float money;
printf("\nEnter the amount of money to be deposited(dollars.cents):");
fgets(line, sizeof(line), stdin);
sscanf(line, "%f", &money);
if(money>0)
{
printf("\n$%.2f has been deposited in your account\n", money);
}
else
printf("\nPlease enter valid amount.......\n");
}
void withdraw()
{
long int rem,f,t,e;
long int mon;
printf("Enter the amount of money to be withdrawn: ");
fgets(line, sizeof(line), stdin);
sscanf(line, "%ld", &mon);
if(mon>=20)
{
if(mon!=30)
{
f=mon/50; /*decides the notes of $50*/
rem=mon%50;
if(rem!=20)
{
if (rem==10||rem==30)
{
f-=1;
rem+=50;
}
}
t=rem/20; /*decides the notes of $20*/
e=rem%20;
if(e==0)
{
printf("\nNos. of 50$ note : %.2ld\n", f);
printf("Nos. of 20$ note : %.2ld\n", t);
printf("TOTAL AMOUNT : %.2ld\n", mon);
}
else
{
printf("\nThis amount is not possible... Please try again\n");
}
}
else /*if amount is not possible*/
{
printf("\nThis amount is not possible... Please try again\n");
}
}
else
{
printf("\nThis amount is not possible... Please try again\n");
}
}
| |