موقع طلبة جامعة البحرين

يمكنك تصفح الموقع كزائر ولكن ندعوك لتسجيل عضوية خاصة بك لتحصل على كافة الصلاحيات مثل تنزيل ملفات المكتبة وقراءة تعليقات هيئة التدريس وغيرها. يمكنك الحصول على عضوية مجانية بالضغط على زر تسجيل. إذا قمت بالتسجيل مسبقا فيمكنك الضغط على زر دخول.

تسجيل دخول
  • قسم المكتبة الجامعية مغلق مؤقتا بعد الاستهداف التي تعرضت له بعض خدمات أمازون في البحرين، جاري استرجاع الملفات ونقلها إلى سيرفرات جديدة وسيتم بعدها اعادة افتتاح المكتبة

ITCS112 - ITCS104 - ITCS102 للفصل الصيفي 2014 - 2015

Write the definition of a class named BankAccount which includes data members and the
prototype of the function members as described below:
The data members of the class BankAccount are: AccountNumber (long), Name (string), and
Balance (float).
The class BankAccount contains the following member functions:
1. A Constructor with default values parameters where the default values are 999 for
AccountNumber, "" for Name, and 0.0 for Balance.
2. Set and get functions for all the data members.
3. Withdraw which is used to withdraw a certain amount X from the Account. It should
check that the balance in the account is at least equal to X (i.e. X or more) before it
allows the withdrawal and reduce the Balance by X.
4. Deposit which is used to Deposit a certain amount Y into the Account. It should of
course increase the Balance by Y.
5. IsAccountEmpty which returns true if the Balance is less than or equal to zero.
Otherwise it returns false.
6. DisplayAccountDetails that prints (on the screen) all the information about the Account.
7. A destructor.

بالنسبة لرقم 3 و 4و 5 شو الحل بالظبط:no:
 
3. Withdraw which is used to withdraw a certain amount X from the Account. It should
check that the balance in the account is at least equal to X (i.e. X or more) before it
allows the withdrawal and reduce the Balance by X

4. Deposit which is used to Deposit a certain amount Y into the Account. It should of
course increase the Balance by Y.

5. IsAccountEmpty which returns true if the Balance is less than or equal to zero.
Otherwise it returns false.



بالنسبة لرقم 3 و 4و 5 شو الحل بالظبط:no:

3 يقولك .. هذي سحب .. يعني واحد بيسحب من الأكاونت Balance قيمه معينه .. فأنت لازم تجيك إذا كان البلنس فيه قد ما يبي يسحب او لا !! إذا في .. اوكي .. إذا مافيه .. يعطيه مسج ان مافيه كثر ما يبي يسحب .. تصير جذي

هذا البروتوتايب مالها في الــPublic

PHP:
public:

    float Withdrawl(float WDrawl);

وهذي الـفنكشن Function

PHP:
float BankAccount::Withdrawl(float WDrawl)
{
    cout<<"Enter An Amount To Withdrawl: ";
    cin>>WDrawl;
    while(WDrawl>Balance)
    {
        cout<<"Sorry, Your Account Balance Is Not That Much!!\n";
        cout<<"Enter An Amount To Withdrawl: ";
            cin>>WDrawl;
        
    }


    Balance=Balance-WDrawl;
    return Balance;
}


..

4 - يقولك احد بيدخل في الحساب مبلغ .. نفس السحب من الحساب بس يفرق الشرط .. اهني بتجيك إذا كان المبلغ الي يبي يودعه 0 .. تقوله مايصير .. غير هذا اوكي

PHP:
public:

float Deposite(float DepositeAmount);

PHP:
float BankAccount::float Deposite(float DepositeAmount)
{
    cout<<"Enter An Amount TO Deposite: ";
    cin>>DepositeAmount;
    while(DepositeAmount=0 || DepositeAmount<0)
    {
        cout<<"Error, invallid amount!!\n";
        cout<<"Please enter an amount to deposite again: ";
        cin>>DepositeAmount;
    }
        
    Balance=Balance+DepositeAmount;
    return Balance;
}

5- راح تجيك إذا كان الـBalance صفر او لا .. إذا صفر رجع له true وإذا لا رجع له false .. فهي bool

PHP:
bool IsAccountEmpty(float Balance)
{
    if(Balance=0 || Balance<0)
        return true;

    else
        return false;

}

نسألكم الدعااء .. التوفيق للجميع يارب
 
4zX81.jpg


أحد عنده فكرة ليش يطلع هذا الشي!
مع ان البروقرام صح :\ و أول مرة طلع الآوت بوت طبيعي
بعدين قام يخرف و يطلع هذا في نهاية الاوت البوت
جربته فجاز ثاني طلع حقي من البداية! :RpS_blink:
​
 
4zX81.jpg


أحد عنده فكرة ليش يطلع هذا الشي!
مع ان البروقرام صح :\ و أول مرة طلع الآوت بوت طبيعي
بعدين قام يخرف و يطلع هذا في نهاية الاوت البوت
جربته فجاز ثاني طلع حقي من البداية! :RpS_blink:
​

شنو الكود؟
 
لما نكتب مثلا
subject :: subject

العلامه (::) وش تعني

وبعد العلامه (~)
وش معناتها ومتى نحطهم ؟
 
لما نكتب مثلا
subject :: subject

العلامه (::) وش تعني

وبعد العلامه (~)
وش معناتها ومتى نحطهم ؟

الـ :: و ~ حالهم حال ; و >> و << و *

لكل symbol وظيفه في ملف الـiostream .. مالنا شغل فيه

بس انتي لازم تعرفين syntax او طريقه كتابه الشغله إلي تبين تكتبينها

مثلا :: تستخدم في الـClass .. متى ؟ بره الـClass

نقول عندكم Class اسمه Subject

class Subject

في هذا الـclass مجموعه الفاريابلز والفنكشنز .. في قسم الـpublic ساعات يقولون اكتب constructor function .. جذي انتي تكتبين
اسم الكلاس::اسم الكلاس ();
Subject::Subject();

وهذي الفنكشن نقدر عن طريقها ان نكتب لكل البرايفت فاريابل قيم تبتدي فيها .. قيم بدائيه

يعني إذا طبعيهم من غير ماتغيري عليهم .. راح يطلعون إلي كتبتيها في فنكشن الكونستراكتر

..

وهذي

PHP:
Subject::~Subject();

بتمسح الكلاس من المومري مال الكمبيوتر

مافيها ولاشئ .. بس ساعات يقول اكتب مسج ان الكلاس تم مسحه

PHP:
Subject::~Subject()
{
    cout<<"The Object Deleted";
}
 
لما نكتب مثلا
subject :: subject

العلامه (::) وش تعني

وبعد العلامه (~)
وش معناتها ومتى نحطهم ؟

لاحظي هذا السؤال

PHP:
Problem 1:   
Write a C++ class including the code of the functions to maintain information about a Date.  The 
class Date data members are day, month, and year. The default values for the day and month is 1, and 
for the year is 1900. In addition, the day must be within 1-31, a month must be within 1-12, and a 
year within 1900-2100.  The class Date function members include the following: 
-  A set function for all data members. 
-  A get function for data member. 
-  A print function to print the data in dd/mm/yyyy format. 
-  A constructor function with default valued parameter to initialize all data members. 
-  A destructor function to print the message “Date Object Terminated”

وهذي الإجابه

PHP:
#include <iostream>
#include <string>
using namespace std;

class Date
{
private:
    int day;
    int month;
    int year;

public:
    void Setallmembers(int ,int , int);
    void Getallmembers(int& ,int& , int& );
    void PrintC();
    Date( );
    ~Date( );
};

void Date::Setallmembers(int d,int m,int y)
{
    day=d;
    month=m;
    year=y;
}

void Date::Getallmembers(int& d,int& m,int& y)
{
    d=day;
    m=month;
    y=year;
}

void Date::PrintC()
{
    cout<<day<<"/"<<month<<"/"<<year;
    cout<<endl;
}

Date::Date()
{
    day=1;
    month=1;
    year=1900;
}

Date::~Date()
{
    cout<<endl;
    cout<<"The Object Termenited";
    cout<<endl;
}

int main()
{
    Date H;
    int d;
    int m;
    int y;

    H.PrintC();
    cout<<endl;

{
        {
        cout<<"Please Insert Day: ";
        cin>>d;
        while(d<1 || d>31)
        {
        cout<<"Error with day, it must be between 1 & 31"<<endl;
        cout<<"Please insert Day again: ";
        cin>>d;
        }

        }

        {
        cout<<"Please Insert Month: ";
        cin>>m;
        while(m<1 || m>12)
        {
        cout<<"Error With Month, it must be between 1 & 12"<<endl;
        cout<<"Please Insert Month Again: ";
        cin>>m;
        }

        }

        {
        cout<<"Please Insert Year: ";
        cin>>y;
        while(y<1900 || m>2100)
        {
        cout<<"Error With Year, it must be between 1900 & 2100"<<endl;
        cout<<"Please Insert Year Again: ";
        cin>>y;
        }
        }
        H.Setallmembers(d,m,y);
}
cout<<endl;

H.PrintC();
//H.~Date();


    return 0;
}
 
هذا سؤال حلو على الـclass وبسيط .. حاولو معاه



Write the definition of a class named BankAccount. The data members of the class BankAccount are: AccountNumber (long), Name (string), and Balance (float). In addition, the class BankAccount contains the following member functions:


Set function, Get function, for all members

Withdraw function which is used to withdraw a certain amount X from the Account. It should check that the balance in
the account is at least equal to X (i.e. X or more) before it allows the withdrawal and reduce the Balance by X

Deposit which is used to Deposit a certain amount Y into the Account. It should of course increase the Balance by Y

. DisplayAccountDetails that prints (on the screen) all the information about the Account.


write a main program to do the following
Declare SavingBankAccount as an array of 5 of type BankAccount

Ask the user to enter the data of 5 accounts and set all members of SavingBankAccount

.Deposit in each account of SavingBankAccounts 100BD

Withdraw from element 2 and 3 30BD.Display all accounts on screen.
 
4zX81.jpg


أحد عنده فكرة ليش يطلع هذا الشي!
مع ان البروقرام صح :\ و أول مرة طلع الآوت بوت طبيعي
بعدين قام يخرف و يطلع هذا في نهاية الاوت البوت
جربته فجاز ثاني طلع حقي من البداية! :RpS_blink:
​

if you sure your code is correct
and still see error message , maybe you have variable you should give it initial value or forget declare one variable
any way,take copy of code and create new project to verify it still has this problem or no , and check in other compiler

If no one of these solutions work , give me the code to check
​
 
هذا سؤال حلو على الـclass وبسيط .. حاولو معاه



Write the definition of a class named BankAccount. The data members of the class BankAccount are: AccountNumber (long), Name (string), and Balance (float). In addition, the class BankAccount contains the following member functions:


Set function, Get function, for all members

Withdraw function which is used to withdraw a certain amount X from the Account. It should check that the balance in
the account is at least equal to X (i.e. X or more) before it allows the withdrawal and reduce the Balance by X

Deposit which is used to Deposit a certain amount Y into the Account. It should of course increase the Balance by Y

. DisplayAccountDetails that prints (on the screen) all the information about the Account.


write a main program to do the following
Declare SavingBankAccount as an array of 5 of type BankAccount

Ask the user to enter the data of 5 accounts and set all members of SavingBankAccount

.Deposit in each account of SavingBankAccounts 100BD

Withdraw from element 2 and 3 30BD.Display all accounts on screen.



هذا تطبيقي
PHP:
#include <iostream>
#include <string>
using namespace std;

class BankAccount{
private:
	long AccountNumber;
	string Name;
	float Balance;
public:
	void SetAccount(long, string, float);
	void getAccount(long &, string &, float &) const;
	void Withdeaw(BankAccount &, float);
	void Deposit(BankAccount &, float);
	void DisplayAccountDetails(BankAccount) const;
	BankAccount();
	~BankAccount();
};

void BankAccount::SetAccount(long AccID, string NAME, float balance)
{
	AccountNumber=AccID;
	Name=NAME;
	Balance=balance;
}

void BankAccount::getAccount(long &AccID, string &NAME, float &balance) const
{
	AccID=AccountNumber;
	NAME=Name;
	balance=Balance;
}

void BankAccount::Withdeaw(BankAccount &TempProcess, float wAmount)
{
	long AccID;
	string Name;
	float Balance, Remaining;
	TempProcess.getAccount(AccID, Name, Balance);
	if(Balance < wAmount)
	{
		cout<<"Failed withdrawal, you cannot withdraw an amount which is higher than your balance!"
			<<endl;
	}
	else
	{
		Remaining=Balance-wAmount;
		TempProcess.SetAccount(AccID, Name, Remaining);
		cout<<"Successfully withdrawed an amount of: "<<wAmount
			<<endl;
	}
}

void BankAccount::Deposit(BankAccount &TempProcess, float dAmount)
{
	long AccID;
	string Name;
	float balance, bSUMd;
	TempProcess.getAccount(AccID, Name, balance);
	if(dAmount<=0)
	{
		cout<<"Error, deposite amount should be grater than 0."
			<<endl;
	}
	else
	{
		bSUMd=balance+dAmount;
		TempProcess.SetAccount(AccID, Name, bSUMd);
		cout<<"Successfully deposited an amount of "<<dAmount
			<<endl;
	}
}

void BankAccount::DisplayAccountDetails(BankAccount Accounts) const
{
	long AccID;
	string Name;
	float balance;
	
	Accounts.getAccount(AccID, Name, balance);
	cout<<"Name: "<<Name<<endl
		<<"Account ID: "<<AccID<<endl
		<<"Balance: "<<balance<<endl;
}

BankAccount::BankAccount()
{
	AccountNumber=0;
	Name="";
	Balance=0.0;
}

BankAccount::~BankAccount()
{
	cout<<"Account deleted."<<endl;
}

int main()
{
	BankAccount SavingBankAccount[5];
	long AccID;
	string Name;
	float Balance, wAmount, dAmount;

	cout<<"Enter data of 5 accounts:"<<endl;
	for(int i=0; i<5; i++)
	{
		cout<<endl<<"Account #"<<i+1<<endl;
		cout<<"Account ID: ";
		cin>>AccID;
		cout<<"Name: ";
		getline(cin, Name);
		getline(cin, Name);
		cout<<"Balance: ";
		cin>>Balance;
		while(Balance<0)
		{
			cout<<"You cannot enter a minus number as an initial balance!"
				<<"\nRe-Enter the balance: ";
			cin>>Balance;
		}
		SavingBankAccount[i].SetAccount(AccID, Name, Balance);
		SavingBankAccount[i].Deposit(SavingBankAccount[i], 100);
		if(i==2 || i==3)
		{
			SavingBankAccount[i].Withdeaw(SavingBankAccount[i], 30);
		}
	}

	cout<<"\n\n******\nALL ACCOUNTS INFO\n******\n"<<endl;
	for(int j=0; j<5; j++)
	{
		cout<<"Account #"<<j+1<<endl;
		SavingBankAccount[j].DisplayAccountDetails(SavingBankAccount[j]);
		cout<<endl<<endl;
	}

	system("pause");
	return 0;
}
 
بقول لكم .. اني نسيت اسجل اي سكشن عندنا فيه امتحان ..

و اليوم مارحت الجامعة ..

فـ ساعدوني و خبروني وين السكاشن الا فيها امتحانات .. :tears:
 
^
طرشي رسالة لإيميل الدكتور مال سكشنكم وبيرد عليج
 
للمشاركه .. User-defined an array

- Delete an item
-Delete a pos
-Bubble sort
-Selection sort

إذا فيه أخطاء خبروني

يفضل استخدام code blocks complier .. ويشتغل على الـMicrosot Visual Studio

PHP:
#include <iostream>
#include <string>
using namespace std;


void deleteposition(int arr[],int&length,int pos)
{
        if(pos>length || pos<0)
        {
        cout<<"pos is out of range";
        return;
        cout<<endl;
        }

        else
        {
        for(int j=pos ; j<length-1 ; j++)
            arr[j]=arr[j+1];

        length--;
        }


}


void deleteitem(int arr[],int&length,int item)
{
    for(int i=0 ; i<length ; i++)
    {
        if(arr[i]==item)
        {
            for(int j=i ; j<length-1 ; j++)
            arr[j]=arr[j+1];

        length--;
        i--;
        }
    }
}

void selectionsort(int arr[],int&length)
{
    int temp=-1;
    int min=0;
    for(int i=0 ; i<length ; i++)
    {
        if(arr[min]>arr[i])
            min=i;
        {
            for(int j=i+1 ; j<length-1 ; j++)
                if(arr[j]>arr[j+1])
                {
                    temp=arr[j];
                    arr[j]=arr[j+1];
                    arr[j+1]=temp;
                }
        }
    }
}

void bubblesort(int arr[],int&length)
{
    int temp=-1;

    for(int j=1 ; j<length ; j++)
    {
        for(int i=0 ; i<length-j ; i++)
        {
             if(arr[i]>arr[i+1])
            {
            temp=arr[i];
            arr[i]=arr[i+1];
            arr[i+1]=temp;
            }
        }
    }



}

void print(int arr[],int&length)
{

    for(int i=0 ; i<length ; i++)
        cout<<arr[i]<<" ";

    cout<<endl;

}


int main(){
    int arr[100];
    int length;
    int pos;
    int item;



    cout<<"Enter The length of the array: ";
    cin>>length;


    cout<<"Enter the array: ";
    for(int i=0 ; i<length ; i++)
        cin>>arr[i];


    print(arr,length);

    cout<<"Enter a item to delete: ";
    cin>>item;

    deleteitem(arr,length,item);

    cout<<endl;

    print(arr,length);

    cout<<"Enter a position to delete: ";
    cin>>pos;

    deleteposition(arr,length,pos);

    bubblesort(arr,length);
    selectionsort(arr,length);

    cout<<endl;

    print(arr,length);






    system("pause");
    return 0;
}


إذا استخدمته على Compiler غير وطلع لك error .. امسح

PHP:
system("pause");


حاضرين للأستفسارات .. وان شاء الله نفيدكم
 
مراجعة للمنتصف insert

كود الـinsert العادي .. تعطيه position وتعطيه item ويضيفه

PHP:
void insertanitem(int arr[],int&length,int pos,int item)
{
    for(int i=length ; i>pos ; i--)
        arr[i]=arr[i-1];

    length++;
    arr[pos]=item;

}


تطبيق على الـinsert

يجمع رقمين ورى بعض .. إذا كانوا اكبر من الرقم الثالث .. يسوي insert لمجموعهم في الخانه الثالثه وبعدين يسوي shift to right إلى ان تمتلئ الـarray - هذا السؤال شفته في امتحان منتصف سابق + ينحل بأكثر من طريقه

PHP:
void insertnumafternum(int arr[],int&length,int maxsize)
{
    if(length>=maxsize)
    cout<<"The Array Is Full";


    else{
    for(int i=0 ; i<length ; i++)
    {
        if(arr[i]+arr[i+1]>arr[i+2])
        {
            for(int j=length ; j>i+3 ; j--)
                arr[j]=arr[j-1];

            length++;
            arr[i+3]=arr[i]+arr[i+1];
        }

    }
    }
}

..

نسألكم الدعاء
 
متى الامتحان؟؟
 
اختي الماس انتي باي سكشن
 
هذا تطبيقي
PHP:
#include <iostream>
#include <string>
using namespace std;

class BankAccount{
private:
	long AccountNumber;
	string Name;
	float Balance;
public:
	void SetAccount(long, string, float);
	void getAccount(long &, string &, float &) const;
	void Withdeaw(BankAccount &, float);
	void Deposit(BankAccount &, float);
	void DisplayAccountDetails(BankAccount) const;
	BankAccount();
	~BankAccount();
};

void BankAccount::SetAccount(long AccID, string NAME, float balance)
{
	AccountNumber=AccID;
	Name=NAME;
	Balance=balance;
}

void BankAccount::getAccount(long &AccID, string &NAME, float &balance) const
{
	AccID=AccountNumber;
	NAME=Name;
	balance=Balance;
}

void BankAccount::Withdeaw(BankAccount &TempProcess, float wAmount)
{
	long AccID;
	string Name;
	float Balance, Remaining;
	TempProcess.getAccount(AccID, Name, Balance);
	if(Balance < wAmount)
	{
		cout<<"Failed withdrawal, you cannot withdraw an amount which is higher than your balance!"
			<<endl;
	}
	else
	{
		Remaining=Balance-wAmount;
		TempProcess.SetAccount(AccID, Name, Remaining);
		cout<<"Successfully withdrawed an amount of: "<<wAmount
			<<endl;
	}
}

void BankAccount::Deposit(BankAccount &TempProcess, float dAmount)
{
	long AccID;
	string Name;
	float balance, bSUMd;
	TempProcess.getAccount(AccID, Name, balance);
	if(dAmount<=0)
	{
		cout<<"Error, deposite amount should be grater than 0."
			<<endl;
	}
	else
	{
		bSUMd=balance+dAmount;
		TempProcess.SetAccount(AccID, Name, bSUMd);
		cout<<"Successfully deposited an amount of "<<dAmount
			<<endl;
	}
}

void BankAccount::DisplayAccountDetails(BankAccount Accounts) const
{
	long AccID;
	string Name;
	float balance;
	
	Accounts.getAccount(AccID, Name, balance);
	cout<<"Name: "<<Name<<endl
		<<"Account ID: "<<AccID<<endl
		<<"Balance: "<<balance<<endl;
}

BankAccount::BankAccount()
{
	AccountNumber=0;
	Name="";
	Balance=0.0;
}

BankAccount::~BankAccount()
{
	cout<<"Account deleted."<<endl;
}

int main()
{
	BankAccount SavingBankAccount[5];
	long AccID;
	string Name;
	float Balance, wAmount, dAmount;

	cout<<"Enter data of 5 accounts:"<<endl;
	for(int i=0; i<5; i++)
	{
		cout<<endl<<"Account #"<<i+1<<endl;
		cout<<"Account ID: ";
		cin>>AccID;
		cout<<"Name: ";
		getline(cin, Name);
		getline(cin, Name);
		cout<<"Balance: ";
		cin>>Balance;
		while(Balance<0)
		{
			cout<<"You cannot enter a minus number as an initial balance!"
				<<"\nRe-Enter the balance: ";
			cin>>Balance;
		}
		SavingBankAccount[i].SetAccount(AccID, Name, Balance);
		SavingBankAccount[i].Deposit(SavingBankAccount[i], 100);
		if(i==2 || i==3)
		{
			SavingBankAccount[i].Withdeaw(SavingBankAccount[i], 30);
		}
	}

	cout<<"\n\n******\nALL ACCOUNTS INFO\n******\n"<<endl;
	for(int j=0; j<5; j++)
	{
		cout<<"Account #"<<j+1<<endl;
		SavingBankAccount[j].DisplayAccountDetails(SavingBankAccount[j]);
		cout<<endl<<endl;
	}

	system("pause");
	return 0;
}


حلو. جميل .. يعطيك العافيه اخوي

انا ماعرف اذا اشتغل عندك لو لا .. احسه معقد وايد هههه .. لاحظ الكودين هذول للايداع والسحب

PHP:
float BankAccount::Withdrawl(float WDrawl)
{
	WDrawl;

	cout<<"Enter An Amount To Withdrawl: ";
	cin>>WDrawl;
	while(WDrawl>Balance)
	{
		cout<<"Sorry, Your Account Balance Is Not That Much!!\n";
		cout<<"Enter An Amount To Withdrawl: ";
			cin>>WDrawl;
		
	}
	

	Balance=Balance-WDrawl;
	return Balance;
}

float BankAccount::Deposit(float DepositeAmount)
{	
	DepositeAmount=100;
	
	cout<<"Enter An Amount To Deposite: ";
	cin>>DepositeAmount;
	while(DepositeAmount<0)
	{
		cout<<"Invallid!!, Re-Enter: ";
			cin>>DepositeAmount;
	}
	
	Balance=Balance+DepositeAmount;
	return Balance;
}
 
سكشن 6 متى واين الاختبار ..؟؟
 
عودة
أعلى أسفل