944,051 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 1782
  • C RSS
Jun 17th, 2007
0

need help with simple bank program

Expand Post »
hi there i am new to this forum and very new to c programming
i do need any of u guyzz there to help me with my assignment
i need to do a simple bank program asking the user password at first with the menu:
1. withdraw
2. balance enquiry
3. change password
4. exit
and i do need to know how to declare clrscr();
i dont know hot to clear screen, how to exit, and when a user selects a menu..... he must return to the main containing the the above thing, and i dont even know how make the change in password coz i use if statement for my password.... is there any other way?

this is my coding... i havent done much but plz help me
and i hope u guyz can help me fast with this


  1.  
  2. #include<stdio.h>
  3. int password,menu,new_password;
  4. float balance,withdraw,withdraw_after;
  5. main()
  6. {
  7. printf("PLEASE ENTER YOUR PASSWORD:\t");
  8. scanf("%d",&password);
  9.  
  10. if(password==123456)
  11. {
  12. balance=1500;
  13. printf("MENU SCREEN\n");
  14. printf("1. Withdraw\n");
  15. printf("2. Balance Enquiry\n");
  16. printf("3. Change Password\n");
  17. printf("4. Exit\n\n");
  18. printf("Select A Menu:\t");
  19. scanf("%d",&menu);
  20. switch(menu)
  21. {
  22. case 1:
  23. printf("Withdraw Menu\n\n");
  24. printf("User Name:\t Tony");
  25. printf("Account Balance:\t RM %.2f",balance);
  26. printf("Enter The Amount You Want To Withdraw:\t");
  27. scanf("%f",&withdraw);
  28.  
  29. if(withdraw>balance)
  30. {
  31. printf("You Don't Have Enough Money In Your Account");
  32. }
  33. else
  34. {
  35. withdraw_after=balance-withdraw;
  36. printf("You Have RM %.2f Left In Your Account",withdraw_after);
  37. }
  38. break;
  39. case 2:
  40. printf("Balance Enquiry Menu\n");
  41. printf("User Name:\t Tony");
  42. printf("Account Balance:\t RM %.2f",balance);
  43. break;
  44. case 3:
  45. printf("Change Password Menu");
  46. printf("Please Enter A New Password:\t");
  47. scanf("%d",new_password);
  48. password=new_password;
  49. break;
  50. case 4:
  51. break;
  52.  
  53. }
  54. }
  55. }
Last edited by weird86; Jun 17th, 2007 at 1:37 pm.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
weird86 is offline Offline
3 posts
since Jun 2007
Jun 17th, 2007
0

Re: help needed with my assignment

>and i do need to know how to declare clrscr();
This is unnecessary.

All your problems would be solved if you drew a flow chart to summarise your problem. Have you done this?
Featured Poster
Reputation Points: 1536
Solved Threads: 431
Posting Expert
iamthwee is offline Offline
5,865 posts
since Aug 2005
Jun 17th, 2007
1

Re: help needed with my assignment

It is better if you use characters for the menu instead of numbers.
Here it is the skeleton of a menu you can use. I made use of the first character of every option as the one the user can choose from.

  1. #include <stdio.h>
  2. #include <ctype.h>
  3.  
  4. #define FALSE 0
  5. #define TRUE !FALSE
  6.  
  7. int main( void )
  8. {
  9. int c;
  10. int done = FALSE;
  11.  
  12. while( !done )
  13. {
  14. puts("\nMENU SCREEN\n");
  15. puts("W - Withdraw\n");
  16. puts("B - Balance Enquiry\n");
  17. puts("C - Change Password\n");
  18. puts("Q - Quit\n");
  19. fputs("Select a choice: ", stdout );
  20. fflush( stdout );
  21.  
  22. c = getchar();
  23. c = toupper( c );
  24.  
  25. switch( c )
  26. {
  27. case 'W':
  28. /* do something here */
  29. break;
  30. case 'B':
  31. /* do something here */
  32. break;
  33. case 'C':
  34. /* do something here */
  35. break;
  36. case 'Q':
  37. done = TRUE; /* Exit here */
  38. break;
  39. default:
  40. puts( "Wrong input, choose again" );
  41. break;
  42. }
  43. }
  44. }
Aia
Reputation Points: 2224
Solved Threads: 218
Nearly a Posting Maven
Aia is offline Offline
2,304 posts
since Dec 2006
Jun 18th, 2007
0

Re: help needed with my assignment

[QUOTE=Aia;389863]It is better if you use characters for the menu instead of numbers.
Here it is the skeleton of a menu you can use. I made use of the first character of every option as the one the user can choose from.



thx 4 the reply man
but there is a prob here man....
at first the program should ask for a password.....
from the password it will determine which account of the user it should open and access..... for example there is 2 user.... 1 wit 1200 balance and 1500 balance.... and the passwords are 123 and 456 for the two users..... when we key in password as 123 it will access the user wit 1200 balance... and if we key in 456 it will accesss the balance 1500...
from there i dont know how to save the balance into the source code...
i cant keep the info in a file cozzz my assignment doesnt let me do it....
is there a way to modify a way to..... for example when the first time i access the account the balance is 1200... and then i take out 200 and there are 1000 left.... without saving the info in a file how to save the new balance so tat when i open again the balance is 1000 or should it b done by saving the balance into file...... if save it into a file... how to do it?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
weird86 is offline Offline
3 posts
since Jun 2007
Jun 18th, 2007
0

Re: help needed with my assignment

Click to Expand / Collapse  Quote originally posted by iamthwee ...
>and i do need to know how to declare clrscr();
This is unnecessary.

All your problems would be solved if you drew a flow chart to summarise your problem. Have you done this?

thx 4 the reply man
i dont really have the flow chart but i know hot the output must come out.... the problem is i dont know how to modify the passsword, the balance and how to save it... refer to my reply to Aia
Reputation Points: 10
Solved Threads: 0
Newbie Poster
weird86 is offline Offline
3 posts
since Jun 2007
Jun 22nd, 2007
0

Re: help needed with my assignment

Click to Expand / Collapse  Quote originally posted by weird86 ...
1. from there i dont know how to save the balance into the source code...
2. i cant keep the info in a file cozzz my assignment doesnt let me do it....
3. without saving the info in a file how to save the new balance so tat when i open again the balance is 1000 or should it b done by saving the balance into file......
4. if save it into a file... how to do it?
1. There 2 basic requirements for storage, A) Temporary B) Persistent.
- Temporary can be achieved using teh structures or arrays or variables (depending on what you wanna store). This would remain in the program memory and be wiped off when you restart your program.
- Persistent can be achieved using many ways e.g. file, database, tape-drive, shared-memory (NOT same as program memory) etc. Again what you choose depends on requirements. E.g. shared memory is very fast, whereas DB will provide you all kind of querying so you don't have to write code for that.
2. If this is the case it's clear that you don't have a requirement to keep data persistently. So go ahead and use one of the temporary methods. I would suggest use a structure.
3. Think a li'l on how to keep data in structures and you'll figure this out.
4. Do you want/need to store data in file or not ?
Reputation Points: 254
Solved Threads: 74
Practically a Posting Shark
thekashyap is offline Offline
804 posts
since Feb 2007
Jul 31st, 2010
-1
Re: help needed with my assignment
please teach how to make a code in turbo C! it is our project.... about DENOMINATION of number.... pls. teach me some simple programs....
Reputation Points: 10
Solved Threads: 0
Newbie Poster
vinsoy is offline Offline
1 posts
since Jul 2010
Jul 31st, 2010
0
Re: help needed with my assignment
i would like you to create your own thread to ask questions and not to use others thread. And as for your answer try to read book " Let us c " by Yashwantrao Kanetkar
Its very good book in simplified language best for beginners.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
newbie_learner is offline Offline
6 posts
since Jul 2010

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: Strange numbers instead of zeros
Next Thread in C Forum Timeline: Home work... i need help...





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC