الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

برنامج ( كشف - ايداع - سحب ) من الحساب ..!

بدأه فارس العصيمي في 21 نوفمبر 2008 · 8 رد · 638 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم وحرمة الله وبركاته

كيف حالكم

هذا برنامج بالدوال للسحب والايداع والكشف بالنسبه للحساب البنكي ..

انا حاولت فيه بس طلع فيه خطئين

وعلى فكره تراي مبتدىء باستخدام الدوال يعني استروا ماوجهتوا

وهذي تجربتي

  1.  
  2. // balancc.cpp : main project file.
  3.  
  4.  
  5.  
  6. [font="Verdana"][color="#000000"][color="#000000"][/color][/color]
  7.  
  8.  
  9.  
  10. #include <iostream>
  11.  
  12. using namespace std;
  13.  
  14. double displayBalance ( double );
  15.  
  16.  
  17.  
  18. double deposit (double , double );
  19.  
  20.  
  21.  
  22. double withdraw (double , double );
  23.  
  24.  
  25.  
  26. int main()
  27.  
  28. {
  29.  
  30. int choice;
  31.  
  32. double balance = 5000.00 ;
  33.  
  34. double withdraw ;
  35.  
  36. double deposit ;
  37.  
  38. while(balance!=0) {
  39.  
  40. cout <<"*******************************************"<<endl;
  41.  
  42.  
  43.  
  44. cout<<"What do you want to do :"<<endl;
  45.  
  46.  
  47.  
  48. cout<<"t 1.Check your balance"<<endl;
  49.  
  50.  
  51.  
  52. cout<<" t 2. Withdraw from your balance"<<endl;
  53.  
  54.  
  55.  
  56. cout<<" t 3. Deposit into your balance"<<endl;
  57.  
  58.  
  59.  
  60. cout<<" t 4. Exit from the program"<<endl;
  61.  
  62.  
  63.  
  64. cout <<"*******************************************"<<endl;
  65.  
  66. cout<<" Enter Your Choice"<<endl;
  67.  
  68. cin>>choice;
  69.  
  70.  
  71.  
  72. switch (choice){
  73.  
  74. case '1':
  75.  
  76. displayBalance ( balance );
  77.  
  78. break;
  79.  
  80. case '2':
  81.  
  82. cout<<"enter amount that you want to withdraw:"<<endl;
  83.  
  84. cin>>withdraw;
  85.  
  86. withdraw ( withdraw , balance ) ;
  87.  
  88.  
  89.  
  90. break ;
  91.  
  92. case '3':
  93.  
  94. cout<<"enter amount that you want to deposit:"<<endl;
  95.  
  96. cin>>deposit;
  97.  
  98. deposit ( deposit , balance ) ;
  99.  
  100. break ;
  101.  
  102. case '4' :
  103.  
  104. cout<<"enter 0 if you want to exit";
  105.  
  106. cin>>balance;
  107.  
  108. break ;
  109.  
  110. default: cout<<"wrong entry";
  111.  
  112. }
  113.  
  114. }
  115.  
  116. return 0;
  117.  
  118. }
  119.  
  120. double displayBalance ( double balance ){
  121.  
  122. return balance ;
  123.  
  124. }
  125.  
  126. double deposit (double deposit , double balance ){
  127.  
  128.  
  129.  
  130. balance = balance + deposit ;
  131.  
  132. return balance ;
  133.  
  134. }
  135.  
  136. double withdraw (double withdraw , double balance ){
  137.  
  138.  
  139.  
  140. balance = balance - withdraw ;
  141.  
  142. return balance ;
  143.  
  144. }
  145.  
  146. [font="Times New Roman"][size="3"]
  147.  

#2

فقط غلطتك انك استخدمت متغيرات بنفس اسم الدوال .

  1. #include <iostream>
  2. using namespace std;
  3.  
  4. double displayBalance ( double );
  5. double deposit (double , double );
  6. double withdraw (double , double );
  7.  
  8. int main()
  9. {
  10. int choice;
  11. double balance = 5000.00 ;
  12. double d_withdraw ;
  13. double d_deposit ;
  14. while(balance!=0) {
  15. cout <<"*******************************************"<<endl;
  16.  
  17. cout<<"What do you want to do :"<<endl;
  18.  
  19. cout<<"t 1.Check your balance"<<endl;
  20.  
  21. cout<<" t 2. Withdraw from your balance"<<endl;
  22.  
  23. cout<<" t 3. Deposit into your balance"<<endl;
  24.  
  25. cout<<" t 4. Exit from the program"<<endl;
  26.  
  27. cout <<"*******************************************"<<endl;
  28. cout<<" Enter Your Choice"<<endl;
  29. cin>>choice;
  30.  
  31. switch (choice){
  32. case '1':
  33. displayBalance ( balance );
  34. break;
  35. case '2':
  36. cout<<"enter amount that you want to withdraw:"<<endl;
  37. cin>>d_withdraw;
  38. withdraw ( d_withdraw , balance ) ;
  39.  
  40. break ;
  41. case '3':
  42. cout<<"enter amount that you want to deposit:"<<endl;
  43. cin>>d_deposit;
  44. deposit ( d_deposit , balance ) ;
  45. break ;
  46. case '4' :
  47. cout<<"enter 0 if you want to exit";
  48. cin>>balance;
  49. break ;
  50. default: cout<<"wrong entry";
  51. }
  52. }
  53. return 0;
  54. }
  55. double displayBalance ( double balance ){
  56. return balance ;
  57. }
  58. double deposit (double d_deposit , double balance ){
  59.  
  60. balance = balance + d_deposit ;
  61. return balance ;
  62. }
  63. double withdraw (double d_withdraw , double balance ){
  64.  
  65. balance = balance - d_withdraw ;
  66. return balance ;
  67. }
  68.  

tvquran_6.gif

#3

لديك خطاء ايضا في سويتش.

انت عرفت choice انها عدد وكتبتها على شكل حرف فقط احذف علامات ' 1' ليصبح 1 والبقيه كذلك.

والدالة displayBalance وايضا المتغير balance يحتاج اسلوب افضل .

تم تعديل هذه المشاركة بواسطة فهدالشلوي في 21 نوفمبر 2008 في 23:10

tvquran_6.gif

#4

اخي فهد

السويتش ما فيها غلط

'1' تحول في الترجمة إلى 49

إي تحول إلى الأسكي

ويمكن مقارنتها بالإنتيجير

الكود في المشاركة الثانية سليم 100%

دولة الخلافة الاسلامية في المخاض الاخير وميلادها قريب

حزب التحرير : التزم الطريق الصحيح الشرعي الوحيد لاعادة دولة الخلافة الاسلامية .

الامة الاسلامية متعطشة لقيادة مخلصة لتذوق حلاوة النصر ولن يكون ذلك الا بعودة الخلافة الاسلامية

الامة الاسلامية تحتاج لاحداث تسحقها سحقا وتمعسها معسا لتفكر تفكيرا جماعيا بالتغير لان وحدة المشاعر لوحدها لاتكفي وهذة الاحداث كلها خير

#5
اقتباس
1' تحول في الترجمة إلى 49

عندما يدخل المستخدم 1 سوف لن يجد الرقم واحد ويخرج من الخيارات.

اذا اردت جرب 49 سوف يقبل وينفذ لكن 1 لن يقبل.

tvquran_6.gif

#6

السلام عليكم ورحمة الله وبركاته

mandareka

مشكوور وماقصرت

بس انا جربت مثل ماقلت بس تطلع غلط

:::

فهد الشلوي

الله يعطيك العافيه

شف طيب انا صلحت هذا

بس عندي مشكلة بداله عرض الحساب

دايم تطلع

5000

حتى لو سويت سحب او ايداع

وهذا الكود

  1. [size="2"][color="#0000ff"]
  2.  
  3.  
  4. #include <iostream>
  5. using namespace std;
  6.  
  7. double displayBalance ( double );
  8. double deposit (double , double );
  9. double withdraw (double , double );
  10.  
  11. int main()
  12. {
  13. int choice;
  14. double balance = 5000.00 ;
  15. double d_withdraw ;
  16. double d_deposit ;
  17. while(balance!=0) {
  18. cout <<"*******************************************"<<endl;
  19.  
  20. cout<<"What do you want to do :"<<endl;
  21.  
  22. cout<<"t 1.Check your balance"<<endl;
  23.  
  24. cout<<" t 2. Withdraw from your balance"<<endl;
  25.  
  26. cout<<" t 3. Deposit into your balance"<<endl;
  27.  
  28. cout<<" t 4. Exit from the program"<<endl;
  29.  
  30. cout <<"*******************************************"<<endl;
  31. cout<<" Enter Your Choice"<<endl;
  32. cin>>choice;
  33.  
  34. switch (choice){
  35. case 1: {
  36. displayBalance (balance);
  37.  
  38. }
  39. break;
  40. case 2:{
  41. cout<<"enter amount that you want to withdraw:"<<endl;
  42. cin>>d_withdraw;
  43. withdraw ( d_withdraw , balance ) ;
  44.  
  45. }
  46. break ;
  47. case 3:{
  48. cout<<"enter amount that you want to deposit:"<<endl;
  49. cin>>d_deposit;
  50. deposit ( d_deposit , balance ) ;
  51.  
  52. }
  53. break ;
  54. case 4 : {
  55. cout<<"enter 0 if you want to exit";
  56. cin>>balance;
  57. }
  58. break ;
  59. default: cout<<"wrong entry"<<endl;
  60. }
  61.  
  62. }
  63. return 0;
  64. }
  65. double displayBalance (double balance){
  66. cout<<"your balance is "<<balance<<" SR " <<endl;
  67. return balance ;
  68. }
  69. double deposit (double d_deposit , double balance ){
  70.  
  71. balance = balance + d_deposit ;
  72. cout<<"Your balance now is :"<< balance<<" SR "<<endl;
  73. return balance ;
  74. }
  75. double withdraw (double d_withdraw , double balance ){
  76.  
  77. balance = balance - d_withdraw ;
  78. if ( balance < 0 )
  79. cout << "can not withdraw from balance"<<endl ;
  80. else
  81. cout<<"Your balance now is :"<< balance <<" SR "<<endl;
  82. return balance ;
  83. }[/color][/size]
  84.  
  85. [size="2"]
  86.  
  87.  
  88. [/size]
  89.  

#7

فقط انقل التعريف الي فوق main

 double balance = 5000.00 ;
tvquran_6.gif

#8

فهدد

نفس المشكله ماتغير

#9

تاكد يا فارس من وضع المتغير فوق الدالة الرئسية وحذفة من الاسفل بمعنى اجعله عام .

tvquran_6.gif

مواضيع مشابهة