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

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

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

ITCS215 للفصل الدراسي الأول 2015 - 2016

ويش الجباتر المطلوبه للمد ترم ؟
وامبي حل tutorial 3 (linked list and ordered linked list ) لو سمحتون :blushing:
 
Extend the class linkedListType by adding the following operations:

1- Write a function noDuplicates that insert an item but before inserting the item it checks whether the item is already in the list. If the item to be inserted is already in the list, the function outputs an appropriate error message.
2- Write a function that returns the info of the kth element of the linked list. If no such element exists, output an appropriate message.


Write a program to test your functions.



Sample Input/Output

Enter the size of the List: 6

Enter a number to be inserted: 5
Enter a number to be inserted: 7
Enter a number to be inserted: 5

Item you are trying to insert is already in the list.

Enter a number to be inserted: 9
Enter a number to be inserted: 1
Enter a number to be inserted: 7

Item you are trying to insert is already in the list.

Enter a number to be inserted: 10
Enter a number to be inserted: 2

The Content of the list is:
5 7 9 1 10 2

Enter an index to return its value: 3
The value of index 3 is : 1


Press any key to continue……


plz help me

اخطاء واجد في الـ main :nosweat:
كود:
void main()[COLOR=#808080]
[/COLOR]{
    linkedListType<int> list;
    int x,y;
    cout<<"Enter the size of the List: ";
    cin>>x;
    y=x;
    while (x>0)
    {
        cout<<"Enter a number to be inserted: ";
        cin>>y;
        if (list.noDuplicates(y))
            x--;
    }
    cout<<endl<<"The Content of the list is:"<<endl;
    for (int i=0;i<y;i++)
    {
        list.retriveAt(i,x);
        cout<<x<<" ";
    }


    cout<<endl<<endl<<"Enter an index to return its value:";
    cin>>x;
    if (list.retriveAt(x,y))
        cout<<"The value of index "<<x<<" is : "<<y<<endl;


    cout<<endl;
}

هذي الجزئية غلط بعد
... orderedLinkedListType<Type>::noDuplicates ...
...
if (found)
list.insertLast(newitem)
الفنكشن تصير في " LinkedListType " على حسب السؤال ..
المفروض تصير "
found==false " أو " found! "
وما يصير نستخدم فنكشن "
insertLast "

بالنسبة للقسم 2 من السؤال ما شفت الفنكشن :nosweat: بس هي بتكون مثل retriveAt
 
اللي عنده حل تتوريال 2 و 3 يحطهم بليييييز :RpS_crying:
 
Add a function reverse () to the class doublyLinkedList, that will reverse the order of all elements in the doubly linked list, your function should display a suitable error message whenever the list is empty or there is only one element in the list otherwise it should perform the reverse operation ( you have to change only the links NOT the info ).
To test your functions write a main program that will create a doubly linked list containing 5 strings ,print the content of the list, then call the reverse function and display the content of the list after reversing it.
You will need to define the following:
1- insertLastNode function inserts a new element at the end of the list.
2- print() function displays the content of the list.
 
نبي نقاش حق الأمتحان باجر
 
معلومات عن مكان الأختبار لو سمحتوا ؟؟؟؟
 
خلاص حصلت

[h=3]Final Exam[/h]Posted on: Saturday, January 4, 2014 8:00:00 AM AST

Dear my students
Good Morning
The final Exam of ITCS215 will be on 04, Jan. 2014 (Saturday) from 11:30 - 1:30 PM.
Section 02 S40-2049
Section 05 S40-2084


Good Luck & best wishes …
 
السلام عليكم

هذا الموضوع مخصص للمناقشة و الاستفسارات
بكل ما يتعلق بمقرر ITCS215

التوفيق جميعاً

:rolleyes2:
 
سكشن 5 ,,
 
التعديل الأخير:
النوتات مال هالاسبوع كامل الله لا يهينكم ,,
اللي يقدر لا يبخل ,,
 
i want hilp to courrect this functhion

template <class Type >
void linkedListType<Type>:: noDuplicates ( elemType item )
{
bool found ;
found =search(item);
{
if ( found)
cout <<
" error ";
else
insertLast( item);
}
}
template <class Type >
Type linkedListType<Type>:: retrieveK (
int pos )
{
nodeType<Type> *cur=first;
if (isEmptyList() )
cout <<
"incorrect";
else
for (int i=0;i=pos;i++)
return cur ->info ;
}
template <class Type >
void linkedListType<Type>:: print ( )
{
nodeType<Type> *cur=first;
while ( cur!=NULL)
{
cout <<cur->info;
cout <<cur->link;
}
}
void main ()
{
cout <<
"Enter the size of the List";
cin>>y;
linkedListType<
int> L(y);
cout<<
"Enter a number to be inserted: ";
cin>>x;
L. noDuplicates ( item x );
L. retrieveK ( pos );
}


hilp me blz ..

 
i want hilp to courrect this functhion

template <class Type >
void linkedListType<Type>:: noDuplicates ( elemType item )
{
bool found ;
found =search(item);
{
if ( found)
cout <<
" error ";
else
insertLast( item);
}
}
template <class Type >
Type linkedListType<Type>:: retrieveK (
int pos )
{
nodeType<Type> *cur=first;
if (isEmptyList() )
cout <<
"incorrect";
else
for (int i=0;i=pos;i++)
return cur ->info ;
}
template <class Type >
void linkedListType<Type>:: print ( )
{
nodeType<Type> *cur=first;
while ( cur!=NULL)
{
cout <<cur->info;
cout <<cur->link;
}
}
void main ()
{
cout <<
"Enter the size of the List";
cin>>y;
linkedListType<
int> L(y);
cout<<
"Enter a number to be inserted: ";
cin>>x;
L. noDuplicates ( item x );
L. retrieveK ( pos );
}


hilp me blz ..


عندكم خلل بسيط :whistling:
ما يصير تستخدمون فنكشن داخل فنكشن ثانية موجوده في مثل الكلاس ..
كود:
template<class Type>
bool linkedListType<Type>::noDuplicates(const Type& item)
{
	nodeType<Type> *curr=first;
	bool f=false;


	while(curr != NULL && !f)
		if(curr->info == item)
			f = true;
		else
			curr = curr->link;
	if (f==false) //Item not found
	{
		nodeType<Type> *newNode; //pointer to create the new node


		newNode = new nodeType<Type>; //create the new node


		assert(newNode != NULL); //If unable to allocate memory, 
		//terminate the program


		newNode->info = item; //store the new item in the node
		newNode->link = NULL; //set the link field of newNode
		//to NULL


		if(first == NULL) //if the list is empty, newNode is 
		//both the first and last node
		{
			first = newNode;
			last = newNode;
			count++; //increment count
		}
		else //the list is not empty, insert newNode after last
		{
			last->link = newNode; //insert newNode after last
			last = newNode; //make last point to the actual last node
			count++; //increment count
		}
		return true;
	}
	else
		cout<<endl<<"Item is exist in the list. "<<endl<<endl;
	return false;
}


template<class Type>
bool linkedListType<Type>::retriveAt(int pos,Type& item)
{
	if (first==NULL)
	{
		cout<<"List is empty"<<endl;
		return false;
	}
	if (pos<0 || pos>= count)
	{
		cout<<"Invalid position"<<endl;
		return false;
	}
	nodeType<Type> *cur=first;
	for (int i=0 ; i<pos ; i++)
		cur=cur->link;
	item=cur->info;
	return true;
}

في المين ما يصير نحدد حجم للأري لأنها linkedList

كود:
void main ()
{
	int x;
	linkedListType<int> L;
	cout<< "Enter a number to be inserted: ";
	cin>>x;
	L.noDuplicates ( x );
	L.print();
}
 
thanx :blushing:
 
ممكن المساعدة في حل السؤال :blushing:
كود:
The file [B]“arrayList.cpp” [/B]is provided to you, please add the following functions to the file provided, don’t start from scratch.
·         A member function [B]min[/B] that returns the smallest element of the list.
·         A member function [B]max[/B] that returns the largest element of the list.
·         A non-member function [B]checksum[/B], that accepts L as the first parameter of type arrayListType, and an integer number X. The function will print the first two elements in the list object L that sum to X, if no numbers in L satisfy the condition the message “No two elements sum to X”.
[B][U]Example[/U][/B]
كود:
[TABLE="align: left"]
[TR]
[TD]2[/TD]
[TD]3[/TD]
[TD]100[/TD]
[TD]51[/TD]
[TD]70[/TD]
[TD]24[/TD]
[TD]49[/TD]
[TD]98[/TD]
[/TR]
[/TABLE]
[LEFT]
For this array and X =100, the function should print  “2 and 98 sums to 100”
           [B][U]Prototype:[/U][/B]
void checksum( arrayListType<Type> &L, Type X);
 
[B][U]Write a simple main to test the previous functions.[/U][/B]

[/LEFT]


و هذا حلي
كود:
#include<cassert>
#include<iostream>
using namespace std;


template<class elemType>
class arrayListType
{
public:
    bool isEmpty();
    bool isFull();
    int  listSize();
    int  maxListSize();
    void print() const;
    bool isItemAtEqual(int location, const elemType& item);
    void insertAt(int location, const elemType& insertItem);
    void insertEnd(const elemType& insertItem);
    void removeAt(int location);
    void retrieveAt(int location, elemType& retItem);
    void replaceAt(int location, const elemType& repItem);
    void clearList();
    int max( arrayListType &m);
    int min( arrayListType &n);
    int  seqSearch(const elemType& item);
    void insert(const elemType& insertItem);
    void remove(const elemType& removeItem);
    arrayListType(int size);
    ~arrayListType();    // destructor
    arrayListType(const arrayListType<elemType>& otherList);
    const arrayListType<elemType>& operator=
            (const arrayListType<elemType>&);
            
protected:
    int maxSize;
    int length;
    elemType* list;
};




template<class elemType>
bool arrayListType<elemType>::isEmpty()
{
    return (length == 0);
}


template<class elemType>
bool arrayListType<elemType>::isFull()
{
    return (length == maxSize);
}


template<class elemType>
int arrayListType<elemType>::listSize()
{
    return length;
}


template<class elemType>
int arrayListType<elemType>::maxListSize()
{
    return maxSize;
}


template<class elemType>
void arrayListType<elemType>::print() const
{
    for(int i = 0; i < length; i++)
        cout<<list[i]<<" ";
    cout<<endl;
}


template<class elemType>
bool arrayListType<elemType>::isItemAtEqual(int location, const elemType& item)
{
    return(list[location] == item); 
}


template<class elemType>
void arrayListType<elemType>::insertAt(int location, const elemType& insertItem)
{
    if(location < 0 || location >= maxSize)
        cerr<<"The position of the item to be inserted is out of range."<<endl;
    else 
        if(length >= maxSize)     // the list is full
            cout<<"Cannot insert in a full list."<<endl;
    else
    {
        for(int i = length; i > location; i--)
            list[i] = list[i-1];   // shift the elements each one position to the right
        list[location] = insertItem;  // insert the item at the specified position
        length++;        
    }
}    


template<class elemType>
void arrayListType<elemType>::insertEnd(const elemType& insertItem)
{
    if(length >= maxSize)  // the list if full
        cout<<"Cannot insert in a full list."<<endl;
    else
    {
        list[length] = insertItem;  // insert the item at the end 
        length++;        
    }
}    


template<class elemType>
void arrayListType<elemType>::removeAt(int location)
{
    if(location < 0 || location >= length)
        cout<<"The location of the item to be removed is out of range."<<endl;
    else
    {
         for(int i = location; i < length - 1; i++) 
            list[i] = list[i+1]; 
        length--;        
    }
}    


template<class elemType>
void arrayListType<elemType>::retrieveAt(int location, elemType& retItem)
{
    if(location < 0 || location >= length)
        cout<<"The location of the item to be retrieved is out of range."<<endl;
    else
    {
         retItem = list[location]; 
    }
}


template<class elemType>
void arrayListType<elemType>::replaceAt(int location, const elemType& repItem)
{
    if(location < 0 || location >= length)
        cout<<"The location of the item to be replaced is out of range."<<endl;
    else
    {
         list[location] = repItem;
    }
}


template<class elemType>
void arrayListType<elemType>::clearList()
{
    length = 0;
}


template<class elemType>
int arrayListType<elemType>::seqSearch(const elemType& item)
{
    int loc;
    bool found = false;
    for(loc = 0; loc < length; loc++) 
        if(list[loc] == item)
        {
            found = true;
            break;
        }
    if(found)
        return loc;
    else 
    return -1;
}


template<class elemType>
void arrayListType<elemType>::insert(const elemType& insertItem)
{       // insert insertItem if it is not in the list
    int loc;
    if(length == 0)
        list[length++] = insertItem;
    else
        if(length == maxSize)
            cout<<"Cannot insert in a full list."<<endl;
        else
        {
            loc = seqSearch(insertItem);
            if(loc == -1)
                list[length++] = insertItem;
            else
                cout<<"Duplication is not allowed"<<endl;
        }
}


template<class elemType>
void arrayListType<elemType>::remove(const elemType& removeItem)
{       
    int loc;
    if(length == 0)
        cout<<"Cannot remove from an empty list"<<endl;
    else
    {
        loc = seqSearch(removeItem);
        if(loc != -1)
            removeAt(loc);
        else
            cout<<"The item to be deleted is not in the list."<<endl;
        }
}


template<class elemType>
arrayListType<elemType>::arrayListType(int size)
{
    if(size < 0)
    {
        cout<<"The array size must be positive. Creating of an array of size 100."<<endl;
        maxSize = 100;
    }
    else
        maxSize = size;
    length = 0;
    list = new elemType[maxSize];
    //assert(list != NULL); // capture programming error
}


template<class elemType>
arrayListType<elemType>::~arrayListType()    // destructor
{
    delete [] list;
}


template<class elemType>
arrayListType<elemType>::arrayListType(const arrayListType<elemType>& otherList)
{
    maxSize = otherList.maxSize;
    length = otherList.length;
    list = new elemType[maxSize];
    assert(list != NULL); // capture programming error
    for(int j = 0; j < length; j++) 
        list[j] = otherList.list[j]; 
}


template<class elemType>
const arrayListType<elemType>& arrayListType<elemType>::operator=
            (const arrayListType<elemType>& otherList)
{
    if(this != &otherList)
    {
        delete [] list;
        maxSize = otherList.maxSize;
        length = otherList.length;
        list = new elemType[maxSize];
        //assert(list != NULL);
        for(int i = 0; i < length; i++) 
            list[i] = otherList.list[i];
    }
    return *this; 
}






template<class elemType>
int arrayListType<elemType>::max(arrayListType<Type> &m)
{
 m=list[0];
for(int i=1;i<length;i++)
if (m<list[i])
{
m=list[i];
}
return m;
}




template<class elemType>
    int arrayListType<elemType>::min(arrayListType<Type> &n)
{
n=list[0];
for(int i=1;i<length;i++)
if (n>list[i])
{
n=list[i];
}
return n;
}
 
ممكن المساعدة في حل السؤال :blushing:
كود:
The file [B]“arrayList.cpp” [/B]is provided to you, please add the following functions to the file provided, don’t start from scratch.
·         A member function [B]min[/B] that returns the smallest element of the list.
·         A member function [B]max[/B] that returns the largest element of the list.
·         A non-member function [B]checksum[/B], that accepts L as the first parameter of type arrayListType, and an integer number X. The function will print the first two elements in the list object L that sum to X, if no numbers in L satisfy the condition the message “No two elements sum to X”.
[B][U]Example[/U][/B]
كود:
[TABLE="align: left"]
[TR]
[TD]2[/TD]
[TD]3[/TD]
[TD]100[/TD]
[TD]51[/TD]
[TD]70[/TD]
[TD]24[/TD]
[TD]49[/TD]
[TD]98[/TD]
[/TR]
[/TABLE]
[LEFT]
For this array and X =100, the function should print  “2 and 98 sums to 100”
           [B][U]Prototype:[/U][/B]
void checksum( arrayListType<Type> &L, Type X);
 
[B][U]Write a simple main to test the previous functions.[/U][/B]

[/LEFT]


و هذا حلي
كود:
#include<cassert>
#include<iostream>
using namespace std;


template<class elemType>
class arrayListType
{
public:
    bool isEmpty();
    bool isFull();
    int  listSize();
    int  maxListSize();
    void print() const;
    bool isItemAtEqual(int location, const elemType& item);
    void insertAt(int location, const elemType& insertItem);
    void insertEnd(const elemType& insertItem);
    void removeAt(int location);
    void retrieveAt(int location, elemType& retItem);
    void replaceAt(int location, const elemType& repItem);
    void clearList();
    int max( arrayListType &m);
    int min( arrayListType &n);
    int  seqSearch(const elemType& item);
    void insert(const elemType& insertItem);
    void remove(const elemType& removeItem);
    arrayListType(int size);
    ~arrayListType();    // destructor
    arrayListType(const arrayListType<elemType>& otherList);
    const arrayListType<elemType>& operator=
            (const arrayListType<elemType>&);
            
protected:
    int maxSize;
    int length;
    elemType* list;
};




template<class elemType>
bool arrayListType<elemType>::isEmpty()
{
    return (length == 0);
}


template<class elemType>
bool arrayListType<elemType>::isFull()
{
    return (length == maxSize);
}


template<class elemType>
int arrayListType<elemType>::listSize()
{
    return length;
}


template<class elemType>
int arrayListType<elemType>::maxListSize()
{
    return maxSize;
}


template<class elemType>
void arrayListType<elemType>::print() const
{
    for(int i = 0; i < length; i++)
        cout<<list[i]<<" ";
    cout<<endl;
}


template<class elemType>
bool arrayListType<elemType>::isItemAtEqual(int location, const elemType& item)
{
    return(list[location] == item); 
}


template<class elemType>
void arrayListType<elemType>::insertAt(int location, const elemType& insertItem)
{
    if(location < 0 || location >= maxSize)
        cerr<<"The position of the item to be inserted is out of range."<<endl;
    else 
        if(length >= maxSize)     // the list is full
            cout<<"Cannot insert in a full list."<<endl;
    else
    {
        for(int i = length; i > location; i--)
            list[i] = list[i-1];   // shift the elements each one position to the right
        list[location] = insertItem;  // insert the item at the specified position
        length++;        
    }
}    


template<class elemType>
void arrayListType<elemType>::insertEnd(const elemType& insertItem)
{
    if(length >= maxSize)  // the list if full
        cout<<"Cannot insert in a full list."<<endl;
    else
    {
        list[length] = insertItem;  // insert the item at the end 
        length++;        
    }
}    


template<class elemType>
void arrayListType<elemType>::removeAt(int location)
{
    if(location < 0 || location >= length)
        cout<<"The location of the item to be removed is out of range."<<endl;
    else
    {
         for(int i = location; i < length - 1; i++) 
            list[i] = list[i+1]; 
        length--;        
    }
}    


template<class elemType>
void arrayListType<elemType>::retrieveAt(int location, elemType& retItem)
{
    if(location < 0 || location >= length)
        cout<<"The location of the item to be retrieved is out of range."<<endl;
    else
    {
         retItem = list[location]; 
    }
}


template<class elemType>
void arrayListType<elemType>::replaceAt(int location, const elemType& repItem)
{
    if(location < 0 || location >= length)
        cout<<"The location of the item to be replaced is out of range."<<endl;
    else
    {
         list[location] = repItem;
    }
}


template<class elemType>
void arrayListType<elemType>::clearList()
{
    length = 0;
}


template<class elemType>
int arrayListType<elemType>::seqSearch(const elemType& item)
{
    int loc;
    bool found = false;
    for(loc = 0; loc < length; loc++) 
        if(list[loc] == item)
        {
            found = true;
            break;
        }
    if(found)
        return loc;
    else 
    return -1;
}


template<class elemType>
void arrayListType<elemType>::insert(const elemType& insertItem)
{       // insert insertItem if it is not in the list
    int loc;
    if(length == 0)
        list[length++] = insertItem;
    else
        if(length == maxSize)
            cout<<"Cannot insert in a full list."<<endl;
        else
        {
            loc = seqSearch(insertItem);
            if(loc == -1)
                list[length++] = insertItem;
            else
                cout<<"Duplication is not allowed"<<endl;
        }
}


template<class elemType>
void arrayListType<elemType>::remove(const elemType& removeItem)
{       
    int loc;
    if(length == 0)
        cout<<"Cannot remove from an empty list"<<endl;
    else
    {
        loc = seqSearch(removeItem);
        if(loc != -1)
            removeAt(loc);
        else
            cout<<"The item to be deleted is not in the list."<<endl;
        }
}


template<class elemType>
arrayListType<elemType>::arrayListType(int size)
{
    if(size < 0)
    {
        cout<<"The array size must be positive. Creating of an array of size 100."<<endl;
        maxSize = 100;
    }
    else
        maxSize = size;
    length = 0;
    list = new elemType[maxSize];
    //assert(list != NULL); // capture programming error
}


template<class elemType>
arrayListType<elemType>::~arrayListType()    // destructor
{
    delete [] list;
}


template<class elemType>
arrayListType<elemType>::arrayListType(const arrayListType<elemType>& otherList)
{
    maxSize = otherList.maxSize;
    length = otherList.length;
    list = new elemType[maxSize];
    assert(list != NULL); // capture programming error
    for(int j = 0; j < length; j++) 
        list[j] = otherList.list[j]; 
}


template<class elemType>
const arrayListType<elemType>& arrayListType<elemType>::operator=
            (const arrayListType<elemType>& otherList)
{
    if(this != &otherList)
    {
        delete [] list;
        maxSize = otherList.maxSize;
        length = otherList.length;
        list = new elemType[maxSize];
        //assert(list != NULL);
        for(int i = 0; i < length; i++) 
            list[i] = otherList.list[i];
    }
    return *this; 
}






template<class elemType>
int arrayListType<elemType>::max(arrayListType<Type> &m)
{
 m=list[0];
for(int i=1;i<length;i++)
if (m<list[i])
{
m=list[i];
}
return m;
}




template<class elemType>
    int arrayListType<elemType>::min(arrayListType<Type> &n)
{
n=list[0];
for(int i=1;i<length;i++)
if (n>list[i])
{
n=list[i];
}
return n;
}

عندكم خلل بسيط في min و max ..
المفروض يصيرون جذي
:smile2:

كود:
template<class elemType>
elemType arrayListType<elemType>::max()
{
	elemType m=list[0];
	for(int i=1;i<length;i++)
		if (m<list[i])
			m=list[i];
	
	return m;
}


template<class elemType>
elemType arrayListType<elemType>::min()
{
	elemType n=list[0];
	for(int i=1;i<length;i++)
		if (n>list[i])
			n=list[i];
	
	return n;
}
 
ادا احد يساعدنا في الحل


Write a function called merge that accepts two array-based lists
list1 and list2 of type arrayListType as parameters. Elements of
list1 are sorted in ascending order.

Whereas,the elements of list2 are not sorted. The function should
insert the elements of list2 in list1 in such a manner that after
insertion also list1 remains sorted.

Assume that class arrayListType is available for use.

Function prototype:



template<class elemType>

bool merge(arrayListType<elemType> &list1,
const arrayListType<elemType> &list2);

Note that the function returns false if both lists list1
and list2 are empty or if list1 becomes full at any stage,
else returns true.


PHP:
template<class elemType>


bool merge(arrayListType<elemType> &list1,
const arrayListType<elemType> &list2);
{
   type elem,item

   if(list1.isEmpty() && list.isEmpty() && list.isFull() )
    
   return false;
   
   for(int i=0 ; i<list1.listsize() || i<list2.listsize() ; i++)
   {
      
      item=list2.retriveAt(i,elem);
      list1.inseartAT(item);
   
   }
    return true
}
 
حلي لأسئلة التوتوريال 1
هل إجاباتي صحيحة ؟

JcBvp3.jpg


FBxONE.jpg


pDOWEV.jpg


6tkPa0.jpg




هذا حلي للسؤال (1)
كود:
class checkingAccount : public bankAccount {
      private :
              double interest, minimumBalance, serviceCharges;
      public :
             void setinterest (double it);
             void setminimumBalance (double min);
             void setserviceCharges (double sc);
             double getinterest ();
             double getminimumBalance ();
             double gerviceCharges ();
             void print ();
             checkingAccount(int,double,double,double,double);
             
             };


وهذا حلي للسؤال (2)

كود:
class car :: public Vehicle {
      
      private :
              string typeOfFuel;
              int sittingCapacity;
              
      public :
             car (string, int, double, string, int);
             void settypeOfFuel (string so);
             void setsittingCapacity (int sc);
             string gettypeOfFuel ();
             int getsittingCapacity ();
             void print ();
             int age ();
             
             
             };
             
             
             car :: car (string c, int y, double p, string so, int sc) : Vehicle (c,y,p) {
                 
                 typeOfFuel=so;
                 sittingCapacity=sc;
                 }
                 
             void car :: print () {
                  Vehicle :: print ();
                  cout<<" type Of Fuel "<<so<<endl;
                  cout<<"sitting Capacity"<<sc<<endl;
                  }
             
             int car :: age () {
                 
                 return (2014 - getYearModel (););
                 }


وهذا حلي للسؤال (3)


كود:
class person {
      protected :
                string name;
                char gender;
      public :
             person (string pesonName, char personGender){
                    name=pesonName;
                    gender=personGender;
                    Date dateOfBirth; 
                    }
                    
             string getName() {
                    return name;}
                    
             char getGender () {
                  return gender;}
                  
             void print () {
                  cout<< " Name :"<<name<<" Gender :"<<gender<<endl;}
                  
                  };
                  
                  
      class Student : public person {
            
            private :
                    long studentidnumber;
                    string major;
            public :
                   void setnumber (long id);
                   void setmajor (string m);
                   long getnumber ();
                   string getmajor ();
                   void print ();
                   Student (string pesonName, char personGender, long id, string m);
                   
                   };
                   

class Date {
      private :
              int day,month,year;
              
      public :
             void setday (int d);
             void setmonth (int m);
             void setyear (int y);
             int getday ();
             int getmonth ();
             int getyear ();
             void print ();
             Date (int d,int m, int y);
             
             };



وهذا حلي للسؤال (4)

كود:
class addressType {
      private :
              int buildingNum;
              int roadNum;
              int blockNum;
              string area;
      public :
             addressType (int bu=0, int ro=0, int bl=0, string ar =" ");
             void setAddress (int bu, int ro, int bl, string ar);
             int gerbBuildingNum ();
             int getRoadNum ();
             int getBblockNum ();
             string Area ();
             void print ();
             
             };

class building : public addressType {
      
      private :
              addressType address;
              float addressType;
              int numOfFloors;
      public :
             void setaddress (addressType add);
             void setaddressType (float addt);
             void setnumOfFloors (int n);
             addressType getaddress ();
             float getaddressType ();
             int getnumOfFloors ();
             void print ();
             building (int bu=0, int ro=0, int bl=0, string ar =" ",float addt,int n);
             
             
             
             };



اتمنى المساعدة اذا عندي خطأ:smile2:
 
Write a member function called DelInst to be included in class doublyLinkedList that takes an element item as parameter. The function compares between the two items with the input item and delete or insert item into list1, as follows: ï‚· List is empty: output message: “This is empty list or list has one item” ï‚· List has only one node: destroy list ï‚· List has two or more than one node: compare between the two consecutive items with the input item and delete the second item if the summation of the two items is smaller than the
input item; otherwise insert the input item into list. Exampl: L1 :2 3 15 23 30 70 Input item 25 After function calling : L1: 2 23 25
30 70 Hint: Sorted Doubly Linked List with Insertion and Deletion opration

PHP:
template<class Type>void doublyLinkedList<Type>::Dlinst ( Type item)    {        nodeType<Type> *current;        nodeType<Type> *Tcurrent;        current=first;        Tcurrent=current->next;            bool found=false;        while (current!=NULL || !found)        {            if(current->info<item &&(Tcurrent->info)<item)            {                deleteNode(Tcurrent->info);                current=current->next;                Tcurrent=current->next;            }
            else found = true;        }                 
    }

احد اعلمني ويش السالفة ويا هالفنكشن​
 
create a text file that contains student number ( 9 digit number ) , year (one of the four years : senior denoted by SE , Junior denoted by JU , sophomore denoted by SO or Freshman denoted by FR), and GPA ( a floating point number greater than 0.0 ). Add at least two students . For example , your text file may contain entries as follow :

201204889 JU 3.5
201012685 SE 2.8

Then write C++ program that uses the file you created above to do the following :
1) display all the contents of the file in a tabular format with the first row being a header row.
2) write to a file that is called StudentGPA.txt only the GPA from the read file.
3) find out the average of GPA​
 
عودة
أعلى أسفل