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

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

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

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

هذ الطريقة للسورت ..

كود:
BankAccount temp;
    for(int i=0 ; i<size-1 ; i++)
    {
        for(int j=i+1 ; j<size; j++)
        {
            int zi,zj;
            SavingAccounts[i].getbalance(zi);
            SavingAccounts[j].getbalance(zj);
            if(zi>zj)
            {
                temp=SavingAccounts[i];
                SavingAccounts[i]=SavingAccounts[j];
                SavingAccounts[j]=temp;
            }
        }
    }

مجرد فهم + تطبيق .. :smile2:

جبتر 10 اكره شي
المشكلة اني مو فاهمته زين
لوقت المدتيرم يصير خيير :RpS_sleep:

مشكور يعطيك العافيه
 
- تتوقعون التست فيه أسئلة فايل ؟ .. لأن ما اتذكر هالدرس من زمان ماخذه 103
أحتمال ضئيل ... بس مو مستحيل ما يجيبون ، تره بسيط ... كود مثال :
PHP:
علشان نستخدم أكواد الفايل
#include<fstream>

int main(){
تعريف الآوتبوت أو الإنبوت
ifstream inputfile;
ofstream output;

فتح ملف الإنبوت لاخذ القيم إلا فيه
inputfile.open("in.txt");

أخذ القيم
inputfile>>num>>name;

إغلاق الملف
inputfile.close();
outputfile.close();
}

- المخطط للفنكشن او للبرنامج الي نرسمه .. يجيبون مثل هالسؤال ؟ .. على دفعتنا قبل ما فيه هالاختراع
أممممم ، حسب كلام د.نهلة ... فتقول بأن فيه flowchart و أحتمال يجي في المنتصف و عطتنا ورقة فيها مثالين للـ flowchart
 
Problem 4 :
a. Design and implement a class named CarType to maintain information about cars. Each car has a type, price , and mileage. The Type of the car can take one of the following values: " Normal " , " Minivan " or " Family " . Note that the default values of type, price and mileage are: " Normal" , 0.0 , 0.0 respectively.

In addition, the class CarType should include the following:
- Set the car details.
- Return the car details.
- Print the car details.
- Check whether a given car type is valid type.
- A constructor with parameter.
- A destructor.

B. Write a function named sortCars that takes as parameters: an array of type CarType and number of cars in the array. The Function should sort the cars in the array in ascedning order based on the car price By using Bubble sort algorithm.

ممكن الحل؟ السؤال في التتوريال:nosweat:
 
a. Write one statement todefine an object named myAccount from the class BankAccount with values of9876543, "Customer”, 2000 for the data members AccountNumber, Name, andBalance respectively. b. Write statements thatwill withdraw an amount of 1000 from the account myAccount then prints thefollowing messages: OpeningBalance: ????Amountof Withdrarwal: 1000.RemainingBalance: ????
Where ???are the values of the previous balance (before the withdrawal) and the newbalance (after the withdrawal) respectively. Use values from the objectmyAccount. Do not put values for these numbers yourself. قوة شعب عندي هالجزء من الاسايمنت مو عارفه احله , الدكتوره تبي الحل قبل الساعه 9 باجر فساعدوني :RpS_crying:

والله مو تخصصي ما افهم هالماده وايد فساعدوني :smile:
 
a. Write one statement todefine an object named myAccount from the class BankAccount with values of9876543, "Customer”, 2000 for the data members AccountNumber, Name, andBalance respectively.b. Write statements thatwill withdraw an amount of 1000 from the account myAccount then prints thefollowing messages: OpeningBalance: ????Amountof Withdrarwal: 1000.RemainingBalance: ????
Where ???are the values of the previous balance (before the withdrawal) and the newbalance (after the withdrawal) respectively. Use values from the objectmyAccount. Do not put values for these numbers yourself. قوة شعب عندي هالجزء من الاسايمنت مو عارفه احله , الدكتوره تبي الحل قبل الساعه 9 باجر فساعدوني :RpS_crying:

والله مو تخصصي ما افهم هالماده وايد فساعدوني :smile:

.. لحين ما غزرنا والناس شيرت << :bleh:

كود:
long acn;
string n;
float b;
BankAccount myAccount(9876543,"Customer",2000);
for (int i=0;i<7;i++)
{
	SavingAccounts[i].getBankAccount(acn,n,b);
		if (acn==9876543&&n=="Customer"&&b==2000)
			cout<<"It is Account N.O"<<i+1<<endl;
}
myAccount.getBankAccount(acn,n,b);
cout<<"OpeningBalance: "<<b;
myAccount.withdrawBankAccount(1000);
myAccount.getBankAccount(acn,n,b);
cout<<" Amountof Withdrarwal: 1000.RemainingBalance: "<<b;
 
مشكور ما قصرتت :)
 
Problem 4 :
a. Design and implement a class named CarType to maintain information about cars. Each car has a type, price , and mileage. The Type of the car can take one of the following values: " Normal " , " Minivan " or " Family " . Note that the default values of type, price and mileage are: " Normal" , 0.0 , 0.0 respectively.

In addition, the class CarType should include the following:
- Set the car details.
- Return the car details.
- Print the car details.
- Check whether a given car type is valid type.
- A constructor with parameter.
- A destructor.

B. Write a function named sortCars that takes as parameters: an array of type CarType and number of cars in the array. The Function should sort the cars in the array in ascedning order based on the car price By using Bubble sort algorithm.

ممكن الحل؟ السؤال في التتوريال:nosweat:

تفضلوا .. :smile2:

كود:
//Noise-X
#include <iostream>
#include <string>
using namespace std ;
class CarType
{
private:
	string type;
	float price,mileage;
public:
	void set (string,float,float);
	void get (string&,float&,float&);
	void print ();
	bool cart (string);
	CarType (string="Normal",float=0.0,float=0.0);
	~CarType();
};
CarType::CarType (string t,float p,float m)
{
	type=t;
	price=p;
	mileage=m;
}
void CarType::set (string t,float p,float m)
{
	type=t;
	price=p;
	mileage=m;
}
void CarType::get (string &t,float &p,float &m)
{
	t=type;
	p=price;
	m=mileage;
}
void CarType::print ()
{
	cout<<"Car type: "<<type<<endl;
	cout<<"Price : "<<price<<endl;
	cout<<"Mileage : "<<mileage<<endl;
}
bool CarType::cart (string t)
{
	if(t=="Normal"||t=="Minivan"||t=="Family")
		return true;
	else
		return false;
}
void sortCars (CarType list[],int size)
{
	CarType temp;
	for (int i=0;i<size-1;i++)
		for (int j=i;j<size;j++)
		{
			string n;float pi,pj,m;
			list[i].get(n,pi,m);
			list[j].get(n,pj,m);
			if (pi>pj)
			{
				temp=list[i];
				list[i]=list[j];
				list[j]=temp;
			}
		}
}
 
ممكن أحد إساعدني, كتبت البروجرام مال هاي السؤال

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. Set and get functions for all the data members.
  2. 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.
  3. Deposit which is used to Deposit a certain amount Y into the Account. It should of course increase the Balance by Y.
  4. IsAccountEmpty which returns true if the Balance is less than or equal to zero.
Otherwise it returns false.

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

Write a main program to declare MyAccount as an object of type BankAccount.

  1. Call function Set to set MyAccount with your name and account number and 100BD in balance.
  2. Deposit 500BD in MyAccount
  3. Print your account details
  4. Withdraw 150BD from MyAccount
  5. print your account details again.

Create a program that

  1. Declare SavingAccounts as an array of 7 objects of BankAccount.
  2. Read the details of SavingAccounts from file ”savings.dat”.
  3. Write a function that uses bubble sort to sort SavingAccounts according to balance.
  4. Print details of SavingAccounts on screen after sorting.

يطلع لي 13 إررس


كود:
#include<iostream>
#include<fstream>
using namespace std;

int x;
int y;

class BankAccount
{private:
long AccountNumber;
string Name;
float Balance;

public:
    void set (long, string, float);
    void get (long&, string&, float&);
    void Withdraw (long&);
    void Deposit (long&);
    bool IsAccountEmpty ();
    void DisplayAccountDetails ();
}

    void BankAccount :: set (long AN, string N, float B){
        AccountNumber = AN; Name = N; Balance = B;}

    void BankAccount :: get (long& AN, string& N, float& B){
        AN = AccountNumber; N = Name; B = Balance;}

    void BankAccount :: Withdraw (long& x){
        cin>>Balance>>x;
        if (Balance > x)
            Balance =- x;
    }

    void BankAccount :: Deposit (long& y){
        cin>>Balance>>y;
        Balance =+ y
    }
    
    bool BankAccount :: IsAccountEmpty (BankAccount& A){
        if (A.Balance <= 0) return true;
        else return false;
    }

    void BankAccount :: DisplayAccountDetails (){
        cout<<AccountNumber<<Name<<Balance;
    }

int main(){

BankAccount MyAccount;

MyAccount.set (20124667, Maryam, 100);
MyAccount.Deposit (500);
MyAccount.DisplayAccountDetails();
MyAccount.Withdraw(150);
MyAccount.DisplayAccountDetails();

BankAccount SavingAccounts[7];  

ifstream fin;
fin.open("saveings.dat");

BankAccount temp;
    for(int i=0 ; i<size-1 ; i++)
    {
        for(int j=i+1 ; j<size; j++)
        {
            int s,h;
            SavingAccounts[i].getbalance(s);
            SavingAccounts[j].getbalance(h);
            if(s>h)
            {
                temp=SavingAccounts[i];
                SavingAccounts[i]=SavingAccounts[j];
                SavingAccounts[j]=temp;
            }
        }
    }

fin.close();
return 0;
}
 
ممكن أحد إساعدني, كتبت البروجرام مال هاي السؤال



يطلع لي 13 إررس


كود:
#include<iostream>
#include<fstream>
using namespace std;

int x;
int y;

class BankAccount
{private:
long AccountNumber;
string Name;
float Balance;

public:
    void set (long, string, float);
    void get (long&, string&, float&);
    void Withdraw (long&);
    void Deposit (long&);
    bool IsAccountEmpty ();
    void DisplayAccountDetails ();
}

    void BankAccount :: set (long AN, string N, float B){
        AccountNumber = AN; Name = N; Balance = B;}

    void BankAccount :: get (long& AN, string& N, float& B){
        AN = AccountNumber; N = Name; B = Balance;}

    void BankAccount :: Withdraw (long& x){
        cin>>Balance>>x;
        if (Balance > x)
            Balance =- x;
    }

    void BankAccount :: Deposit (long& y){
        cin>>Balance>>y;
        Balance =+ y
    }
    
    bool BankAccount :: IsAccountEmpty (BankAccount& A){
        if (A.Balance <= 0) return true;
        else return false;
    }

    void BankAccount :: DisplayAccountDetails (){
        cout<<AccountNumber<<Name<<Balance;
    }

int main(){

BankAccount MyAccount;

MyAccount.set (20124667, Maryam, 100);
MyAccount.Deposit (500);
MyAccount.DisplayAccountDetails();
MyAccount.Withdraw(150);
MyAccount.DisplayAccountDetails();

BankAccount SavingAccounts[7];  

ifstream fin;
fin.open("saveings.dat");

BankAccount temp;
    for(int i=0 ; i<size-1 ; i++)
    {
        for(int j=i+1 ; j<size; j++)
        {
            int s,h;
            SavingAccounts[i].getbalance(s);
            SavingAccounts[j].getbalance(h);
            if(s>h)
            {
                temp=SavingAccounts[i];
                SavingAccounts[i]=SavingAccounts[j];
                SavingAccounts[j]=temp;
            }
        }
    }

fin.close();
return 0;
}


الاسم maryam يخلونه بين " "
s h خليه float
بعد المفروض تسوين فنكشن ل getbalance مايصير تستخدمينه وانتين ما سويتينه
size بعد ماعرفتينinteger
 
3dltah o ba3d y6la3ley 8 errors

كود:
#include<iostream>
#include<fstream>
using namespace std;

int x;
int y;

class BankAccount
{private:
long AccountNumber;
string Name;
float Balance;

public:
    void set (long, string, float);
    void get (long&, string&, float&);
    void getbalance (float&);
    void Withdraw (long);
    void Deposit (long);
    bool IsAccountEmpty ();
    void DisplayAccountDetails ();
}

    void BankAccount :: set (long AN, string N, float B){
        AccountNumber = AN; Name = N; Balance = B;}

    void BankAccount :: get (long& AN, string& N, float& B){
        AN = AccountNumber; N = Name; B = Balance;}

    void BankAccount :: getbalance (float& B){
        B = Balance;}

    void BankAccount :: Withdraw (long& x){
        cin>>Balance>>x;
        if (Balance > x)
            Balance =- x;
    }

    void BankAccount :: Deposit (long& y){
        cin>>Balance>>y;
        Balance =+ y;
    }
    
    bool BankAccount :: IsAccountEmpty (BankAccount& A){
        if (A.Balance <= 0) return true;
        else return false;
    }

    void BankAccount :: DisplayAccountDetails (){
        cout<<AccountNumber<<Name<<Balance;
    }

int main(){

int size;
BankAccount MyAccount;

MyAccount.set (20124667, "Maryam", 100);
MyAccount.Deposit (500);
MyAccount.DisplayAccountDetails();
MyAccount.Withdraw(150);
MyAccount.DisplayAccountDetails();

BankAccount SavingAccounts[7];  

ifstream fin;
fin.open("saveings.dat");

BankAccount temp;
    for(int i=0 ; i<size-1 ; i++)
    {
        for(int j=i+1 ; j<size; j++)
        {
            float s,h;
            SavingAccounts[i].getbalance(s);
            SavingAccounts[j].getbalance(h);
            if(s>h)
            {
                temp=SavingAccounts[i];
                SavingAccounts[i]=SavingAccounts[j];
                SavingAccounts[j]=temp;
            }
        }
    }

fin.close();
return 0;
}

el s2al

The data members of the class BankAccount are: AccountNumber (long), Name (string), and Balance (float).

The class BankAccount contains the following member functions:


  1. Set and get functions for all the data members.
  2. 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.
  3. Deposit which is used to Deposit a certain amount Y into the Account. It should of course increase the Balance by Y.
  4. IsAccountEmpty which returns true if the Balance is less than or equal to zero.

Otherwise it returns false.


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


Write a main program to declare MyAccount as an object of type BankAccount.


  1. Call function Set to set MyAccount with your name and account number and 100BD in balance.
  2. Deposit 500BD in MyAccount
  3. Print your account details
  4. Withdraw 150BD from MyAccount
  5. print your account details again.


Create a program that


  1. Declare SavingAccounts as an array of 7 objects of BankAccount.
  2. Read the details of SavingAccounts from file ”savings.dat”.
  3. Write a function that uses bubble sort to sort SavingAccounts according to balance.
  4. Print details of SavingAccounts on screen after sorting.

plz sa3doony
 
التعديل الأخير:
عدلت الارورز بس بعد البرنامج فيه خلل الوت بوت ما يطلع صح
ومادرري ليش الكود صاير مخربط :nosweat:

PHP:
#include
<iostream>

#include
<string>

#include
<fstream>

using
 namespace std;



class
 BankAccount

{
private:

long
 AccountNumber;

string Name;

float
 Balance;


public
:

    
void set (long, string, float);

    
void get (long&, string&, float&);

    
void getbalance (float&);

    
void Withdraw (float);

    
void Deposit (float);

    
bool IsAccountEmpty ();

    
void DisplayAccountDetails ();

};


    
void BankAccount :: set (long AN, string N, float B){

        AccountNumber = AN; Name = N; Balance = B;}


    
void BankAccount :: get (long& AN, string& N, float& B){

        AN = AccountNumber; N = Name; B = Balance;}


    
void BankAccount :: getbalance (float& B){

        B = Balance;}


    
void BankAccount :: Withdraw (float x){

        

        
if (Balance > x)

            Balance -= x;

    }


    
void BankAccount :: Deposit (float y){

   

        Balance += y;

    }

    

    
bool BankAccount :: IsAccountEmpty (){

        
if (Balance <= 0) return true;

        
else return false;

    }


    
void BankAccount :: DisplayAccountDetails (){

        cout<<AccountNumber<<Name<<Balance;

    }


int
 main(){


int
 size ;

long
 AN;

string N;

float
 B;

BankAccount MyAccount;


MyAccount.set (20124667, 
"Maryam", 100);

MyAccount.Deposit (500);

MyAccount.DisplayAccountDetails();

MyAccount.Withdraw(150);

MyAccount.DisplayAccountDetails();


BankAccount SavingAccounts[7];  


ifstream fin;

fin.open(
"saveings.dat");


for
 ( int i=0; i<7 ; i++ )

    { fin>>AN>>N>>B; SavingAccounts[i].set(AN,N,B); }


BankAccount temp;

    
for(int i=0 ; i<size-1 ; i++)

    {

        
for(int j=i+1 ; j<size; j++)

        {

            
float s,h;

            SavingAccounts[i].getbalance(s);

            SavingAccounts[j].getbalance(h);

            
if(s>h)

            {

                temp=SavingAccounts[i];

                SavingAccounts[i]=SavingAccounts[j];

                SavingAccounts[j]=temp;

            }

        }

    }


    
for ( int i=0; i<7 ; i++ )

    {SavingAccounts[i].DisplayAccountDetails ();}


fin.close();

return
 0;

}
 
ممكن أحد إساعدني, كتبت البروجرام مال هاي السؤال



يطلع لي 13 إررس

}[/CODE]

أول شي التعريف للسترنق

كود:
#include<string>

ثاني شي لكل فيريابل في البرايفت سوي get فنكشن بهالطريقة

كود:
string getName ();

كود:
string BankAccount :: getName()
{
return Name;
}

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

Withdraw ما فيها براميترز
مجرد داخله اف استيتمنت حسب المطلوب
فلما تسوين ليها كول مجرد الاوبجكت.البروتوتايب فنكشن

Deposit البراميتر انتجر
كود:
void Didposit (int y);
مهمتها انكريز البالانس
يعني
كود:
balance+=y;
بدون سي ان .. لأنش في المين لما تسوين كول فنكشن بتحطين انتجر مكان البراميتر y

A.Balance <= 0
اهني الغلط ان البالانس برايفت
يعني لازم ناخذ قيمته عبر getBalance();

شوفي هذي الأخطاء
و اذا فيه شي ثاني خبرينا ^^
 
سلام عليكم .. شخباركم اخواني واخواتي .. بغيت اسالكم .. محتوى المد تيرم في شنو راح يكون ؟؟ strings / Applications of arrays / structs /classes .. بس هذلين لو ويانه البوينتر ؟؟ :rolleyes2:
 
سلام عليكم .. شخباركم اخواني واخواتي .. بغيت اسالكم .. محتوى المد تيرم في شنو راح يكون ؟؟ strings / Applications of arrays / structs /classes .. بس هذلين لو ويانه البوينتر ؟؟ :rolleyes2:

عليكم السلام و الرحمة
بس هذلين
 
سويته لكن في جزء مبقدره عليه. شلون اقره من فايل؟

Create a program that

  1. Declare SavingAccounts as an array of 3 objects of BankAccount.
  2. Read the details of SavingAccounts from file ”savings.dat”.
  3. Write a function that uses bubble sort to sort SavingAccounts according to balance.
  4. Print details of SavingAccounts on screen after sorting.

كود:
    BankAccount SavingAccounts[3];  


    ifstream fin;
    fin.open("saveings.dat");
    sort (SavingAccounts, 3); 
    for (int i=0; i<3; ++i){
        SavingAccounts[i].DisplayAccountDetails();
        cout<<endl;
    };
    fin.close();

    system ("pause");

    return 0;
}
 
سويته لكن في جزء مبقدره عليه. شلون اقره من فايل؟

Create a program that

  1. Declare SavingAccounts as an array of 3 objects of BankAccount.
  2. Read the details of SavingAccounts from file ”savings.dat”.
  3. Write a function that uses bubble sort to sort SavingAccounts according to balance.
  4. Print details of SavingAccounts on screen after sorting.

كود:
    BankAccount SavingAccounts[3];  


    ifstream fin;
    fin.open("saveings.dat");
    sort (SavingAccounts, 3); 
    for (int i=0; i<3; ++i){
        SavingAccounts[i].DisplayAccountDetails();
        cout<<endl;
    };
    fin.close();

    system ("pause");

    return 0;
}
اول شيء تحتاجين for loop و تقرأينهم عن طريق متغيّرات مثلا
PHP:
fin>>numberaccount>>name>>balance
و بعدين تستخدمين الـ set function إلا في الـ class مثلا :
PHP:
SavingAccounts[i].setnum(numberaccount);
 
ممكن احد يفهمني شسالفة toupper &tolower .. هو شكله كان ويانه في المقرر السابق بس نسيته ..

مثال :
PHP:
include<iostream>
#include<string>
using namespace std;
void main()
{
 
s[0]=toupper(s[0]);
for(int i=0;i<s.size();i++)
{
if(s[i]==' ')
s[i+1]=toupper(s[i+1])
 }
for(i=0;i<s.size();i++)
{
cin>>s[i]
}
{
for(i=0;i<s.size();i++)
{
cout<<s[i];
 
ممكن احد يفهمني شسالفة toupper &tolower .. هو شكله كان ويانه في المقرر السابق بس نسيته ..

مثال :
PHP:
include<iostream>
#include<string>
using namespace std;
void main()
{
 
s[0]=toupper(s[0]);
for(int i=0;i<s.size();i++)
{
if(s[i]==' ')
s[i+1]=toupper(s[i+1])
 }
for(i=0;i<s.size();i++)
{
cin>>s[i]
}
{
for(i=0;i<s.size();i++)
{
cout<<s[i];

+1

هالشي جديد عليي !! :mellow:
 
ممكن احد يفهمني شسالفة toupper &tolower .. هو شكله كان ويانه في المقرر السابق بس نسيته ..

مثال :
PHP:
include<iostream>
#include<string>
using namespace std;
void main()
{
 
s[0]=toupper(s[0]);
for(int i=0;i<s.size();i++)
{
if(s[i]==' ')
s[i+1]=toupper(s[i+1])
 }
for(i=0;i<s.size();i++)
{
cin>>s[i]
}
{
for(i=0;i<s.size();i++)
{
cout<<s[i];
toupper تحول الحروف الى capital letters
و tolower تحولهم الى small letters
 
اهاا .. طلع شي بايخ يعني واني عافسة الدنيا .. شكراا لكمم :smile2:
 
عودة
أعلى أسفل