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

لو سمحتم اريد شخص يساعدني في تصحيح الكود "كود صغير"

بدأه مريتعي في 2 أبريل 2009 · 7 رد · 786 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

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

لو سمحتم يامبرمجينا العرب

ابي منكم خدمه الله يوفقكم وهي

عندي كود سويته مدري حاولت حست بس احس مو منطقي يعني تخربطت في الفقره رقم ثلاثه إن شاء الله مو صعب عليكم

السؤال كان

A bank needs to keep information about clients. For any client, an account number is issued before he/she is allowed to use bank services. The account number is generated automatically and once established it can’t be modified. In addition, name, contact number, amount, account type [golden or silvery] are kept in system.

Write a program to implement the following tasks:

1. Deposit money [increase money of current balance]

2. Withdraw money [decrease money of current balance]

3. Use non class member function which takes object/s as argument to compare two account type and return the account number of the client with golden account; if they are same, the account number of the oldest client will be returned. [Note that this function can access private data members of the class directly]

اما بالنسبه لحلي هو:

#include<iostream>
using namespace std;

class bank
{
private:

string name;

long contactnumber;

int amount;

enum type{golden,sliver};

const int accountnumber;

public:

static int ss=1234;

bank(int n,long s,int z,type t):accountnumber(ss)
{
name=n;

contactnumber=s;

amount=z;
t=golden;
ss++;

}

int Deposit_money(int m)
{
 return amount+=m;
}

int Withdraw_money (int s)
{
	if(amount>0)
	{
	 amount-=s;
	 }
	 return amount;
}

friend string compare_two_account_type (bank b1,bank b2);
};
 string compare_two_account_type (bank b1,bank b2)
 {
   if(b1.type==b2.type)
   {
	 if(b1.accountnumber<b2.accountnumber)
	 {

	 return b1.account number;
	 }
	 else
	 return b2.accountnumber;
	 }
	 else if(b1.type==golden)
	 {
		  return b1.accountnumber;
	 }

	return b2.accountnumber;
}

int main()
{
bank b("Aaa",6587567,80000,golden)
bank b2("Asm",8768688,897978,sliver)

b.Deposit_money(777);
b.Withdraw_money (550);
b.compare_two_account_type;
b2Deposit_money(777);
b2Withdraw_money (550);
b2compare_two_account_type;
return 0;
}

:wacko: :wub: :blink:

تم تعديل هذه المشاركة بواسطة مريتعي في 2 أبريل 2009 في 22:26

#2

لاحول ولاقوه الابالله

وشفيه منتداكم مو زي اول ابدا تغير

الله يهديكم

#3

يا خوووووووووووووك اشرح خطوه خطوه وبعون الله كلنا معاك

لكم مني خالص التقدير

*********************

دروس الاكسس

قاعدة بيانات بالسي++

قاعدة بيانات اخرى بالسي++

الفريق العربي للبرمجه

*********************

كان الله في عون العبد مادام العبد في عون اخيه

#4

مافهمت وش اشرح

السؤال موجود

متاكد انه كله صح

ماعدا الفقره الثالثه هي الي حاس انه خربوطه

ساعدوني اللله يساعدكم

لاتقولون ماحاولت

يوم كامل وانا اقحص عليها

#5

أراها منطقية. لماذا لا تعجبك؟

Do as I say, not as I do

We are Anonymous. We are Legion. We don't forgive. We don't forget

#6

لان الكومبايلر لم تعجبه :blink:

لله يامحسنين لله يامحسنين

اي واحد يجي يلعن ابو هالكود

الثالثاء عندي مد

مسااااااااااااااااااااااااااااااااااعده ترى اليوم جمعه ومطر

الي بيساعدني بدعي له

#7

بســم الله الـرحمــن الرحيــم

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

اهلا اخي

الباين بنكك صعب للغاية ما يسمح بالسحب على الاحمر :lol:

if(amount>0)

ثم عندك خطا في استخدام دالة المقارنة انظر للتصريح

string compare_two_account_type (bank b1,bank b2)

وانظر كيف استخدمتها في مثالك السابق

b.compare_two_account_type;

وايظا

b2.compare_two_account_type;

توجد عدة طرق لحل مثالك وهذه احدها

#include <iostream>
#include <cstring>
using namespace std;

int accountNo = 0;

enum AccountType
{
Golden,
Sliver
};

class Client
{ 

public:
friend CompareAccounts(Client a , Client b);

/* 
Client()
{
} 
*/ 

Client(string cl_name, string cl_contact, double cl_amount,AccountType cl_act_type)
{
  AccountID = accountNo;
  accountNo++;

  Name		= cl_name.c_str();
  ContactInfo = cl_contact.c_str();
  Amount	  = cl_amount;
  accountType = cl_act_type;
}

~Client()
{
}

void Deposit(double inc)
{
  Amount = Amount + inc;
}

void Withdraw(double dec)
{
  Amount = Amount - dec;
}

double Balance(void)
{
  return Amount;
}


private:

int AccountID;
string Name;
string ContactInfo;
double Amount;
AccountType accountType;
};

int CompareAccounts(Client a , Client b)
{

if (a.accountType != b.accountType)
{
  if(a.accountType == Golden)
   return a.AccountID;

return b.AccountID;

}

if( a.AccountID > b.AccountID  )
  return b.AccountID;

return a.AccountID;

}


int main()
{

Client Ali("Ali","Libya",500000,Golden);
Client other("other","somewhere",100000,Sliver);
Client another("another","unKnown",100000,Golden);

cout << CompareAccounts(Ali,other)	   << endl;
cout << CompareAccounts(Ali,another)	 << endl;
cout << CompareAccounts(another,other)   << endl;

other.Deposit(200000);
another.Withdraw(50000);

cout << "other.Balance   = " << other.Balance()   << endl;
cout << "another.Balance = " << another.Balance() << endl;

cout << CompareAccounts(another,other) << endl;

return 0;
}

تحياتي

تم تعديل هذه المشاركة بواسطة HaTy في 3 أبريل 2009 في 17:28

while( "اسلام" )
{
 cout >> "الموت لبني صهيون" >> endl;
}
return "فلسطين";
#8

شكراااااااااااااااااا من الاعمااااااااااااااااااااااااااااااااااااااااااااااااااااااااااااااااااااااااااا

اااااااااااااااق

:clapping: الله يوفقك يازلمه ويرضى عليك

تسلملي ليبيا B)

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

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…