C Board  

Go Back   C Board > General Programming Boards > C Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 02-21-2008, 09:59 AM   #1
Registered User
 
Join Date: Feb 2008
Posts: 23
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...
lesrhac03 is offline   Reply With Quote
Old 02-21-2008, 10:02 AM   #2
Mysterious C++ User
 
Join Date: Oct 2007
Posts: 14,099
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.
__________________
Using: Microsoft Windows™ 7 Professional (x64), Microsoft Visual Studio™ 2008 Team System
I dedicated my life to helping others. This is only a small sample of what they said:
"Thanks Elysia. You're a programming master! How the hell do you know every thing?"
Quoted... at least once.
Quote:
Originally Posted by cpjust
If C++ is 2 steps forward from C, then I'd say Java is 1 step forward and 2 steps back.
Elysia is offline   Reply With Quote
Old 02-21-2008, 10:12 AM   #3
Registered User
 
Join Date: Sep 2006
Posts: 2,506
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.

Adak is online now   Reply With Quote
Old 02-21-2008, 10:22 AM   #4
CSharpener
 
vart's Avatar
 
Join Date: Oct 2006
Posts: 5,242
use int main()

Why when selected the deposit you are asking how much to withdraw?
__________________
If I have eight hours for cutting wood, I spend six sharpening my axe.
vart is offline   Reply With Quote
Old 02-21-2008, 10:39 AM   #5
Super unModrator
 
Join Date: Dec 2007
Posts: 321
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("%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>
abh!shek is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting an error with OpenGL: collect2: ld returned 1 exit status Lorgon Jortle C++ Programming 6 05-08-2009 08:18 PM
how do you resolve this error? -EquinoX- C Programming 32 11-05-2008 04:35 PM
Quantum Random Bit Generator shawnt C++ Programming 62 06-18-2008 10:17 AM
using c++ in c code hannibar C Programming 17 10-28-2005 09:09 PM
Problem with Visual C++ Object-Oriented Programming Book. GameGenie C++ Programming 9 08-29-2005 11:21 PM


All times are GMT -6. The time now is 11:41 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22