# Thread: This is a simple program.. Help me please I think it has an error..

1. ## This is a simple program.. Help me please I think it has an error..

Write a program that will be used to handle Automated Teller Machine Transactions. Such transaction includes; (1) balance inquiry, (2) deposit, (3) withdrawal and say (4) exit. Aside from these, the user should be presented a menu showing these transactions as possible options. (20pts)

Additional Requirements:
1. Initial balance is 10,000.00.
2. Deposit amount should be greater than zero, if the user enters zero or negative amount, the program should print “Deposit amount should be greater than zero”.
3. Withdrawal amount should not exceed the available balance, if the user enters amount greater than the available balance, the program should print “Withdrawal amount exceeds the available balance.
4. Withdrawal amount should be greater than zero, if the user enters zero or negative amount, the program should print “Withdrawal amount should be greater than zero.”
5. Maximum withdrawal amount is 4000.00 per transaction, if the user enters more than 4000.00, the program should print “Maximum withdrawal amount is 4000.00.”
6. The program should print the current balance for every transaction.
7. The program should end if and only if the user chooses to exit.

Heres my program..
Code:
```#include <stdio.h>
#include <conio.h>
double amount=10000.00;
double dep(double y){
double newaccount;
newaccount=amount+y;
return newaccount;}
double with(double x){
double newaccount;
if(x>=4001)
printf("The largest amount you can withdraw is 4000");
else if(x>=10001)
printf("You exceed to your bank savings");
else
newaccount=amount-x;
printf("%lf",newaccount);
return 0;}

void main()
{
int i=0;
double j;
clrscr();
printf("\n*******MENU*********\n");
printf("1.Balance Enquiry\n");
printf("2.Deposit\n");
printf("3.Withdraw\n");
printf("4.Exit\n");
printf("Select an item from the menu: ");
scanf("%d",&i);
while(i<4)
{
switch(i)
{
case 1:printf("This is your balance amount: %f",amount);
break;
case 2:printf("How much would you like to withdraw?");
scanf("%lf",&j);

amount = with(j);
j=0;
printf("This is your balance amount: %f",amount);
break;
case 3:printf("How much amount do want to withdraw?\n");
scanf("%lf",&j);
amount = amount-j;
j=0;
printf("This is your balance amount: %f",amount);
break;
}
printf("\n*********MENU*********...\n");
printf("1.Balance Enquiry\n");
printf("2.Deposit\n");
printf("3.Withdraw\n");
printf("4.Exit\n");
printf("If you are a first time user please deposit some amount for balance enquiry.\n");
printf("Select an item from the menu: ");
scanf("%d",&i);
}
getch();
}```
I think i did not accomplish the requirements..

1. Deposit amount should be greater than zero, if the user enters zero or negative amount, the program should print “Deposit amount should be greater than zero”.
2. Withdrawal amount should not exceed the available balance, if the user enters amount greater than the available balance, the program should print “Withdrawal amount exceeds the available balance.
3. Withdrawal amount should be greater than zero, if the user enters zero or negative amount, the program should print “Withdrawal amount should be greater than zero.”
4. Maximum withdrawal amount is 4000.00 per transaction, if the user enters more than 4000.00, the program should print “Maximum withdrawal amount is 4000.00.”
5. The program should print the current balance for every transaction.

So please I hope someone help me to this... I'm so confuse.. and its really confusing...
Thanks for the help...

2. This code is entirely unreadable. Please indent the code and repost it. If you need help, you can look here.
Another note is that you should not use void main. Use int main instead.
You can also replace getch with getchar.

3. And if you'll just tell us what the program is doing wrong, we'll look into it, as soon as you indent your code so it's readable.

4. use int main()

Why when selected the deposit you are asking how much to withdraw?

5. You can make a single menu() function instead of repeating the same thing twice.
You defined the function dep() but never really used it ??

Code:
```case 2:printf("How much would you like to withdraw?");
scanf("&#37;lf",&j);

amount = with(j);
j=0;
printf("This is your balance amount: %f",amount);```
option 2 is for deposit and you are asking how much to withdraw!

and as others said--indent, use int main(), return 0, getchar() instead of getch() and get rid of <conio.h>

Popular pages Recent additions