![]() |
| |||||||
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 |
| Registered User Join Date: Feb 2008
Posts: 23
| This is a simple program.. Help me please I think it has an error.. 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();
}
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 | |
| | #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:
| |
| Elysia is offline | |
| | #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 | |
| | #4 |
| CSharpener 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 | |
| | #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);
and as others said--indent, use int main(), return 0, getchar() instead of getch() and get rid of <conio.h> |
| abh!shek is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
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 |