السلام عليكم وحرمة الله وبركاته
كيف حالكم
هذا برنامج بالدوال للسحب والايداع والكشف بالنسبه للحساب البنكي ..
انا حاولت فيه بس طلع فيه خطئين
وعلى فكره تراي مبتدىء باستخدام الدوال يعني استروا ماوجهتوا
وهذي تجربتي
- // balancc.cpp : main project file.
- [font="Verdana"][color="#000000"][color="#000000"][/color][/color]
- #include <iostream>
- using namespace std;
- double displayBalance ( double );
- double deposit (double , double );
- double withdraw (double , double );
- int main()
- {
- int choice;
- double balance = 5000.00 ;
- double withdraw ;
- double deposit ;
- while(balance!=0) {
- cout <<"*******************************************"<<endl;
- cout<<"What do you want to do :"<<endl;
- cout<<"t 1.Check your balance"<<endl;
- cout<<" t 2. Withdraw from your balance"<<endl;
- cout<<" t 3. Deposit into your balance"<<endl;
- cout<<" t 4. Exit from the program"<<endl;
- cout <<"*******************************************"<<endl;
- cout<<" Enter Your Choice"<<endl;
- cin>>choice;
- switch (choice){
- case '1':
- displayBalance ( balance );
- break;
- case '2':
- cout<<"enter amount that you want to withdraw:"<<endl;
- cin>>withdraw;
- withdraw ( withdraw , balance ) ;
- break ;
- case '3':
- cout<<"enter amount that you want to deposit:"<<endl;
- cin>>deposit;
- deposit ( deposit , balance ) ;
- break ;
- case '4' :
- cout<<"enter 0 if you want to exit";
- cin>>balance;
- break ;
- default: cout<<"wrong entry";
- }
- }
- return 0;
- }
- double displayBalance ( double balance ){
- return balance ;
- }
- double deposit (double deposit , double balance ){
- balance = balance + deposit ;
- return balance ;
- }
- double withdraw (double withdraw , double balance ){
- balance = balance - withdraw ;
- return balance ;
- }
- [font="Times New Roman"][size="3"]
