help needed with my assignment

Reply

Join Date: Jun 2007
Posts: 3
Reputation: weird86 is an unknown quantity at this point 
Solved Threads: 0
weird86 weird86 is offline Offline
Newbie Poster

need help with simple bank program

 
0
  #1
Jun 17th, 2007
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.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,264
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: help needed with my assignment

 
0
  #2
Jun 17th, 2007
>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?
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 2,029
Reputation: Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of 
Solved Threads: 176
Aia's Avatar
Aia Aia is offline Offline
Postaholic

Re: help needed with my assignment

 
1
  #3
Jun 17th, 2007
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. }
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 3
Reputation: weird86 is an unknown quantity at this point 
Solved Threads: 0
weird86 weird86 is offline Offline
Newbie Poster

Re: help needed with my assignment

 
0
  #4
Jun 18th, 2007
[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?
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 3
Reputation: weird86 is an unknown quantity at this point 
Solved Threads: 0
weird86 weird86 is offline Offline
Newbie Poster

Re: help needed with my assignment

 
0
  #5
Jun 18th, 2007
Originally Posted by iamthwee View Post
>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
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 539
Reputation: thekashyap will become famous soon enough thekashyap will become famous soon enough 
Solved Threads: 50
thekashyap's Avatar
thekashyap thekashyap is offline Offline
Posting Pro

Re: help needed with my assignment

 
0
  #6
Jun 22nd, 2007
Originally Posted by weird86 View Post
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 ?
Are you Agile.. ?
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC