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

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

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

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

سلام
ممكن تشوفون ليي الغلط في هالبرنامج
يطلع ليي 29 ايرور
HTML:
#include<iostream>#include <string>using namespace std;struct nameType{string firstName;string lastName;};struct dateType{int day;int month;int year;};struct personalInfoType {long ID;nameType name;int salary;dateType  DateOfBirth;};personalInfoType Emp1 ;void getData(personalInfoType Employees[], int numEmployee){cout<<"enter your name,id and DateofBirth";for(int i=0;i<numEmployee;i++)cin>>Employees[i].ID>>Employees[i].name.firstName>>Employees[i].name.lastName>>Employees[i].DateofBirth.day>>Employees[i].DateofBirth.month>>Employees[i].DateOfBirth.day;}void printData(    personalInfoType Employees[],int numEmployee){for(int i=0;i<numEmployee;i++)cout<<Employees[i].ID<<endl;cout<<Employees[i].name.firstName<<endl;cout<<Employees[i].name.lastName<<endl;cout<<Employees[i].DateofBirth.year<<endl,cout<<Employees[i].DateOfBirth.month<<endl;cout<<Employees[i].DateOfBirth.day<<endl;}void bornSameYearMonth(personalInfoType Employees[], int numEmployee,personalInfoType  Emp1){for (int i=0,i<numEmployee;i++){if (Emp1.DateofBirth.year==Employees[i].DateofBirth.year&&Emp1.DateOfBirth.day==Employees[i].DateOfBirth.day)cout<<Employees[i].name.firstName<<endl;cout<<Employees[i].name.lastName<<endl;    }}    void PrintLowSalaries(personalInfoType Employees[],int numEmployee){cout<<"theemployees with salary less than 200 are";for (int i=0; i<numEmployee; i++){if (Employees[i].salary<200)cout<<Employees[i].ID<<endl;cout<<Employees[i].name.lastName<<endl;}

عدلتهم ..

كود:
#include<iostream>
#include <string>
using namespace std;
struct nameType
{
	string firstName;string lastName;
};
struct dateType
{
	int day;int month;int year;
};
struct personalInfoType 
{
	long ID;nameType name;
	int salary;
	dateType  DateOfBirth;
};
personalInfoType Emp1 
;void getData(personalInfoType Employees[], int numEmployee)
{
	cout<<"enter your name,id and DateofBirth";
	for(int i=0;i<numEmployee;i++)
		cin>>Employees[i].ID>>Employees[i].name.firstName>>Employees[i].name.lastName>>Employees[i].DateOfBirth.day>>Employees[i].DateOfBirth.month>>Employees[i].DateOfBirth.day;
}
void printData(	personalInfoType Employees[],int numEmployee)
{
	for(int i=0;i<numEmployee;i++)
	{
		cout<<Employees[i].ID<<endl;
		cout<<Employees[i].name.firstName<<endl;
		cout<<Employees[i].name.lastName<<endl;
		cout<<Employees[i].DateOfBirth.year<<endl;
		cout<<Employees[i].DateOfBirth.month<<endl;
		cout<<Employees[i].DateOfBirth.day<<endl;
	}
}
void bornSameYearMonth(personalInfoType Employees[], int numEmployee,personalInfoType  Emp1)
{
	for (int i=0;i<numEmployee;i++)
	{
		if (Emp1.DateOfBirth.year==Employees[i].DateOfBirth.year&&Emp1.DateOfBirth.day==Employees[i].DateOfBirth.day)
			cout<<Employees[i].name.firstName<<endl;cout<<Employees[i].name.lastName<<endl;	
	}
}
void PrintLowSalaries(personalInfoType Employees[],int numEmployee)
{
	cout<<"theemployees with salary less than 200 are";
	for (int i=0; i<numEmployee; i++)
	{
		if (Employees[i].salary<200)cout<<Employees[i].ID<<endl;cout<<Employees[i].name.lastName<<endl;
	}
}
 
عندي مشكلة
اي برنامج اكتبه يطلع فيه نفس الايرور
Too many include files
؟؟!!
 
عندي مشكلة
اي برنامج اكتبه يطلع فيه نفس الايرور
Too many include files
؟؟!!
 
شكرا اخ Noise-X

اشتغل البرنامج الحين :99:
 

[TD="bgcolor: #ffffff"] Home Assignment
Rewrite the program of Lab4
PART A:
Add The definition of a struct named Date with the following members:
day
month
year.

PART B:
Assuming that a book can have more than one author(maximum 4 authors), redefine the struct bookType to include also:
an array authors,
an integer number representing the number of authors
the date of publication
PART C:
Write a main function to test your program.
Reads at least data of 4 books
Call function displayTopRating to print all authors of books with high rating.
Note: Need to rewrite the function displayTopRating and main function
[/TD]
 
ممكن حل السؤال بأسرع وقت ممكن.

Write a program that reads employee ID, names, address, and position. The program should output each employee’s name followed by the address and position. The output should be printed from the highest position to the lowest position.
Employee data should be stored in struct variable of type employeeType which has five components: employeeId of type integer, struct of type employeeName (which has two components, empFirstName and empLastName of type string), address of type string, positionCode of type integer(positionCode is between 103 to 108), and positionName of type string. The following table shows the position codes with its corresponding value of position names.​
[TABLE="align: left"]
[TR]
[TD="align: left"]103
[/TD]
[TD="align: left"]Principal
[/TD]
[/TR]
[TR]
[TD="align: left"]104
[/TD]
[TD="align: left"]Assistant Principal
[/TD]
[/TR]
[TR]
[TD="align: left"]105
[/TD]
[TD="align: left"]Curriculum Coordinator
[/TD]
[/TR]
[TR]
[TD="align: left"]106
[/TD]
[TD="align: left"]Personnel Director
[/TD]
[/TR]
[TR]
[TD="align: left"]107
[/TD]
[TD="align: left"]Supervisor
[/TD]
[/TR]
[TR]
[TD="align: left"]108
[/TD]
[TD="align: left"]Head Teacher
[/TD]
[/TR]
[/TABLE]




Suppose that the company has 20 employees. Use an array of 20 components of type employeeType.
Your program must contain at least the following functions:​


  • [*=left]A function to read the employees’ data into the array.
    [*=left]A function to sort the employees’ data from the highest position to the lowest position.
    [*=left]A function to print the employees’ names and their position names after sorting into a file. Your program must output each employee’s name in this form: last name followed by a comma, followed by a space, followed by the first name, and the name must be left-justified.
 
ممكن حل السؤال بأسرع وقت ممكن.

Write a program that reads employee ID, names, address, and position. The program should output each employee’s name followed by the address and position. The output should be printed from the highest position to the lowest position.
Employee data should be stored in struct variable of type employeeType which has five components: employeeId of type integer, struct of type employeeName (which has two components, empFirstName and empLastName of type string), address of type string, positionCode of type integer(positionCode is between 103 to 108), and positionName of type string. The following table shows the position codes with its corresponding value of position names.​
[TABLE="align: left"]
[TR]
[TD="align: left"]103
[/TD]
[TD="align: left"]Principal
[/TD]
[/TR]
[TR]
[TD="align: left"]104
[/TD]
[TD="align: left"]Assistant Principal
[/TD]
[/TR]
[TR]
[TD="align: left"]105
[/TD]
[TD="align: left"]Curriculum Coordinator
[/TD]
[/TR]
[TR]
[TD="align: left"]106
[/TD]
[TD="align: left"]Personnel Director
[/TD]
[/TR]
[TR]
[TD="align: left"]107
[/TD]
[TD="align: left"]Supervisor
[/TD]
[/TR]
[TR]
[TD="align: left"]108
[/TD]
[TD="align: left"]Head Teacher
[/TD]
[/TR]
[/TABLE]




Suppose that the company has 20 employees. Use an array of 20 components of type employeeType.
Your program must contain at least the following functions:​


  • [*=left]A function to read the employees’ data into the array.
    [*=left]A function to sort the employees’ data from the highest position to the lowest position.
    [*=left]A function to print the employees’ names and their position names after sorting into a file. Your program must output each employee’s name in this form: last name followed by a comma, followed by a space, followed by the first name, and the name must be left-justified.

الحلول الجاهزة ممنوعة ، ممكن احد يشرح لش السؤال او تحطين جوابش و يصححونه :smile:
 
ممكن حل السؤال بأسرع وقت ممكن.

Write a program that reads employee ID, names, address, and position. The program should output each employee’s name followed by the address and position. The output should be printed from the highest position to the lowest position.
Employee data should be stored in struct variable of type employeeType which has five components: employeeId of type integer, struct of type employeeName (which has two components, empFirstName and empLastName of type string), address of type string, positionCode of type integer(positionCode is between 103 to 108), and positionName of type string. The following table shows the position codes with its corresponding value of position names.​
[TABLE="align: left"]
[TR]
[TD="align: left"]103[/TD]
[TD="align: left"]Principal[/TD]
[/TR]
[TR]
[TD="align: left"]104[/TD]
[TD="align: left"]Assistant Principal[/TD]
[/TR]
[TR]
[TD="align: left"]105[/TD]
[TD="align: left"]Curriculum Coordinator[/TD]
[/TR]
[TR]
[TD="align: left"]106[/TD]
[TD="align: left"]Personnel Director[/TD]
[/TR]
[TR]
[TD="align: left"]107[/TD]
[TD="align: left"]Supervisor[/TD]
[/TR]
[TR]
[TD="align: left"]108[/TD]
[TD="align: left"]Head Teacher[/TD]
[/TR]
[/TABLE]




Suppose that the company has 20 employees. Use an array of 20 components of type employeeType.
Your program must contain at least the following functions:​


  • [*=left]A function to read the employees’ data into the array.
    [*=left]A function to sort the employees’ data from the highest position to the lowest position.
    [*=left]A function to print the employees’ names and their position names after sorting into a file. Your program must output each employee’s name in this form: last name followed by a comma, followed by a space, followed by the first name, and the name must be left-justified.


كود:
#include <iostream>#include <string>
using namespace std;
struct employeename
{
	string first;
	string last;
};
struct employeeType
{
	int employeeid;
	string adress;
	int positioncode[];
	string positionName;
	employeename name;
};


void reademp(employeeType& emp)
{
	cout<<"Enter ID, adress, position code, position name, first name and last name:"<<endl;
	cin>>emp.employeeid>>emp.positioncode>>emp.positionName;
	cin>>emp.name.first>>emp.name.last;
}
void sortemp(employeeType& list[], int size)
{
	int iteration,i;
	string temp;


	for (iteration=0; iteration<size-1; iteration++)
		for (i=0; i<size-iteration-1; i++)
			if (list[i].positioncode > list[i+1].positioncode)
			{
				temp = list[i];
				list[i] = list[i+1];
				list[i+1] = temp;
				
			}
}
void printemp(employeeType em[])
{
	for (int i=0; i<20; i++)
		cout<<em[i].positioncode<<" "<<em[i].name.first<<", "<<em[i].name.last;
	cout<<endl;
}
void main()
{
}

شباب لو ماعليكم أمر اتعدلون الاغلاط اللي في الكود :nosweat::sad_1:
 
ممكن حل السؤال بأسرع وقت ممكن.

Write a program that reads employee ID, names, address, and position. The program should output each employee’s name followed by the address and position. The output should be printed from the highest position to the lowest position.
Employee data should be stored in struct variable of type employeeType which has five components: employeeId of type integer, struct of type employeeName (which has two components, empFirstName and empLastName of type string), address of type string, positionCode of type integer(positionCode is between 103 to 108), and positionName of type string. The following table shows the position codes with its corresponding value of position names.​
[TABLE="align: left"]
[TR]
[TD="align: left"]103[/TD]
[TD="align: left"]Principal[/TD]
[/TR]
[TR]
[TD="align: left"]104[/TD]
[TD="align: left"]Assistant Principal[/TD]
[/TR]
[TR]
[TD="align: left"]105[/TD]
[TD="align: left"]Curriculum Coordinator[/TD]
[/TR]
[TR]
[TD="align: left"]106[/TD]
[TD="align: left"]Personnel Director[/TD]
[/TR]
[TR]
[TD="align: left"]107[/TD]
[TD="align: left"]Supervisor[/TD]
[/TR]
[TR]
[TD="align: left"]108[/TD]
[TD="align: left"]Head Teacher[/TD]
[/TR]
[/TABLE]




Suppose that the company has 20 employees. Use an array of 20 components of type employeeType.
Your program must contain at least the following functions:​


  • [*=left]A function to read the employees’ data into the array.
    [*=left]A function to sort the employees’ data from the highest position to the lowest position.
    [*=left]A function to print the employees’ names and their position names after sorting into a file. Your program must output each employee’s name in this form: last name followed by a comma, followed by a space, followed by the first name, and the name must be left-justified.


كود:
#include <iostream>#include <string>
using namespace std;
struct employeename
{
    string first;
    string last;
};
struct employeeType
{
    int employeeid;
    string adress;
    int positioncode[];
    string positionName;
    employeename name;
};


void reademp(employeeType& emp)
{
    cout<<"Enter ID, adress, position code, position name, first name and last name:"<<endl;
    cin>>emp.employeeid>>emp.positioncode>>emp.positionName;
    cin>>emp.name.first>>emp.name.last;
}
void sortemp(employeeType& list[], int size)
{
    int iteration,i;
    string temp;


    for (iteration=0; iteration<size-1; iteration++)
        for (i=0; i<size-iteration-1; i++)
            if (list[i].positioncode > list[i+1].positioncode)
            {
                temp = list[i];
                list[i] = list[i+1];
                list[i+1] = temp;
                
            }
}
void printemp(employeeType em[])
{
    for (int i=0; i<20; i++)
        cout<<em[i].positioncode<<" "<<em[i].name.first<<", "<<em[i].name.last;
    cout<<endl;
}
void main()
{
}

شباب لو ماعليكم أمر اتعدلون الاغلاط اللي في الكود :nosweat::sad_1:

تفضلوا ... ,:smile2:

كود:
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
struct employeename
{
	string empFirstName ;
	string empLastName ;
};
struct employeeType
{
	int employeeid;
	string adress;
	int positioncode;
	string positionName;
	employeename name;
};
employeeType UOB[20];
void reademp (employeeType emp[],int size)
{
	for (int i=0;i<size;i++)
	{
		cout<<"Enter ID : ";
		cin>>emp[i].employeeid;
		cout<<"Enter adress : ";
		cin>>emp[i].adress;
		cout<<"Enter position code 'between 103-108' : ";
		do{cin>>emp[i].positioncode;}while(emp[i].positioncode<102 && emp[i].positioncode>109);
		cout<<"Enter first name and last name: ";
		cin>>emp[i].name.empFirstName>>emp[i].name.empLastName;
		cout<<"Enter positionName : ";
		cin>>emp[i].positionName;
		cout<<endl;
	}
}
void sortemp(employeeType list[], int size)
{
	employeeType temp;
	for (int i=0; i<size-1; i++)
		for (int j=i+1; j<size; j++)
			if (list[i].positioncode > list[j].positioncode)
			{
				temp = list[i];
				list[i] = list[j];
				list[j] = temp;
			}
}
void printemp(employeeType em[],int size)
{
	ofstream out;
	out.open("outfile.txt");
	for (int i=0; i<size; i++)
	{
		cout<<i+1<<" )  "<<em[i].positioncode<<" "<<em[i].name.empLastName<<", "<<em[i].name.empFirstName<<endl;
		out<<i+1<<" )  "<<em[i].positioncode<<" "<<em[i].name.empLastName<<", "<<em[i].name.empFirstName<<endl;
	}
	cout<<endl;
	out.close();
}
void main()
{
	int size;
	cout<<"Number of Employees ' >= 20' : ";
	do{cin>>size;}while(size>20 && size<0);
	cout<<endl;
	reademp(UOB,size);
	cout<<"\n\n        <]==================================================[>\n\n";
	sortemp(UOB,size);
	cout<<"Names after sorting:\n";
	printemp(UOB,size);
}
 
التعديل الأخير:
تفضلوا ... ,:smile2:

كود:
#include <iostream>
#include <string>
using namespace std;
struct employeename
{
    string empFirstName ;
    string empLastName ;
};
struct employeeType
{
    int employeeid;
    string adress;
    int positioncode;
    string positionName;
    employeename name;
};
employeeType UOB[20];
void reademp (employeeType emp[],int size)
{
    for (int i=0;i<size;i++)
    {
        cout<<"Enter ID : ";
        cin>>emp[i].employeeid;
        cout<<"Enter adress : ";
        cin>>emp[i].adress;
        cout<<"Enter position code 'between 103-108' : ";
        do{cin>>emp[i].positioncode;}while(emp[i].positioncode<102 && emp[i].positioncode>109);
        cout<<"Enter first name and last name: ";
        cin>>emp[i].name.empFirstName>>emp[i].name.empLastName;
        cout<<"Enter positionName : ";
        cin>>emp[i].positionName;
        cout<<endl;
    }
}
void sortemp(employeeType list[], int size)
{
    employeeType temp;
    for (int i=0; i<size-1; i++)
        for (int j=i+1; j<size; j++)
            if (list[i].positioncode > list[j].positioncode)
            {
                temp = list[i];
                list[i] = list[j];
                list[j] = temp;
            }
}
void printemp(employeeType em[],int size)
{
    for (int i=0; i<size; i++)
        cout<<i+1<<" )  "<<em[i].positioncode<<" "<<em[i].name.empLastName<<", "<<em[i].name.empFirstName<<endl;
    cout<<endl;
}
void main()
{
    int size;
    cout<<"Number of Employees ' >= 20' : ";
    do{cin>>size;}while(size>20 && size<0);
    cout<<endl;
    reademp(UOB,size);
    cout<<"\n\n        <]==================================================[>\n\n";
    sortemp(UOB,size);
    cout<<"Names after sorting:\n";
    printemp(UOB,size);
}

أخوي .. مو المفروض تخليه في فايل ؟؟
 
>> A function to print the employees’ names and their position names after sorting into a file
 
أخوي .. مو المفروض تخليه في فايل ؟؟
>> A function to print the employees’ names and their position names after sorting into a
file


مشكورين على الملاحظة .. :nosweat:
ما أنتبهت ليها :RpS_tongue:

الحل أن نعدل آخر فنكشن بس ..

كود:
void printemp(employeeType em[],int size)
{
	ofstream out;
	out.open("outfile.txt");
	for (int i=0; i<size; i++)
	{
		cout<<i+1<<" )  "<<em[i].positioncode<<" "<<em[i].name.empLastName<<", "<<em[i].name.empFirstName<<endl;
		out<<i+1<<" )  "<<em[i].positioncode<<" "<<em[i].name.empLastName<<", "<<em[i].name.empFirstName<<endl;
	}
	cout<<endl;
	out.close();
}
 
  1. Add to the program of your previous lab a new struct called DateType with 3 members (day, month and year).


  1. Redefine the struct CarType to hold the following :

  1. seating capacity(int)
  2. price (float)
  3. received date(DateType)
  4. colors[10] array of colors (array of strings).
  5. Number of colors available.


b) Rewrite the following functions.

  1. Write a function that read one data of one car.
void readcar (CarType &X) {………..}


  1. Write a function that output the specifications of one car.
void outputcar (CarType X) {………..}

c)In the main function:
a. Declare an array named cars of the data type CarType.
b. Enter an integer NB for car number.
c. Reads data of NB cars.
c. Output specification of all cars received in October 2012.(10/2012)


طبعا انا حليت نصه تقريبا بس شيرت و ما عرفت التكمله


اخر شي مشير انا ....

لاهنتوو الحل :( :sad_1:
 
كود:
[COLOR=#0000ff][COLOR=#0000ff][COLOR=#0000ff] [FONT=Consolas][SIZE=2]#include[/SIZE][/FONT][/COLOR][/COLOR][/COLOR][COLOR=#a31515][COLOR=#a31515][COLOR=#a31515][FONT=Consolas][SIZE=2]<string>[/SIZE][/FONT]
[/COLOR][/COLOR][/COLOR][COLOR=#0000ff][COLOR=#0000ff][COLOR=#0000ff][FONT=Consolas][SIZE=2]using[/SIZE][/FONT][/COLOR][/COLOR][/COLOR][SIZE=2][FONT=Consolas][COLOR=#0000ff][FONT=Consolas][COLOR=#0000ff][FONT=Consolas][COLOR=#0000ff]namespace[/COLOR][/FONT][/COLOR][/FONT][/COLOR][/FONT][FONT=Consolas][FONT=Consolas][COLOR=#000000] std;[/COLOR]
[/FONT][/FONT][/SIZE][FONT=Consolas][COLOR=#0000ff][FONT=Consolas][COLOR=#0000ff][FONT=Consolas][COLOR=#0000ff][SIZE=2]struct[/SIZE][/COLOR][/FONT][/COLOR][/FONT][/COLOR][/FONT][FONT=Consolas][FONT=Consolas][SIZE=2][COLOR=#000000] DateType[/COLOR][/SIZE]
[SIZE=2]{[/SIZE]
[/FONT][/FONT][FONT=Consolas][COLOR=#0000ff][FONT=Consolas][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][/COLOR][/FONT][/COLOR][/FONT][FONT=Consolas][FONT=Consolas][SIZE=2] day ,month year ;[/SIZE]
[SIZE=2]};[/SIZE]
[/FONT][/FONT][FONT=Consolas][COLOR=#0000ff][FONT=Consolas][COLOR=#0000ff][FONT=Consolas][COLOR=#0000ff][SIZE=2]struct[/SIZE][/COLOR][/FONT][/COLOR][/FONT][/COLOR][/FONT][FONT=Consolas][FONT=Consolas][SIZE=2][COLOR=#000000] cartype[/COLOR][/SIZE]
[SIZE=2]{[/SIZE]
[/FONT][/FONT][FONT=Consolas][COLOR=#0000ff][FONT=Consolas][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][/COLOR][/FONT][/COLOR][/FONT][FONT=Consolas][FONT=Consolas][SIZE=2] seatingcapacity;[/SIZE]
[/FONT][/FONT][FONT=Consolas][COLOR=#0000ff][FONT=Consolas][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]float[/COLOR][/SIZE][/FONT][/COLOR][/FONT][/COLOR][/FONT][FONT=Consolas][FONT=Consolas][SIZE=2] price;[/SIZE]
[SIZE=2]datetype receiveddate;[/SIZE]
[SIZE=2]string colors[10];[/SIZE]
[/FONT][/FONT][FONT=Consolas][COLOR=#0000ff][FONT=Consolas][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][/COLOR][/FONT][/COLOR][/FONT][FONT=Consolas][FONT=Consolas][SIZE=2] noc;[/SIZE]
[SIZE=2]};[/SIZE]
[/FONT][/FONT][FONT=Consolas][COLOR=#0000ff][FONT=Consolas][COLOR=#0000ff][FONT=Consolas][COLOR=#0000ff][SIZE=2]void[/SIZE][/COLOR][/FONT][/COLOR][/FONT][/COLOR][/FONT][FONT=Consolas][FONT=Consolas][SIZE=2][COLOR=#000000] readcar (CarType &X) [/COLOR][/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]cin>>cartype.seatingcapacity>>cartype.price>>cartype.datetype.receiveddate>>cartype.colors[10]>>cartype.noc;[/SIZE]
[SIZE=2]}[/SIZE]
[/FONT][/FONT][FONT=Consolas][COLOR=#0000ff][FONT=Consolas][COLOR=#0000ff][FONT=Consolas][COLOR=#0000ff][SIZE=2]void[/SIZE][/COLOR][/FONT][/COLOR][/FONT][/COLOR][/FONT][FONT=Consolas][FONT=Consolas][SIZE=2][COLOR=#000000] outputcar (CarType X) [/COLOR][/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]cout<<cartype.seatingcapacity<<cartype.price<<cartype.datetype.receiveddate<<cartype.colors[10]<<cartype.noc;[/SIZE]
[SIZE=2]}[/SIZE]
[/FONT][/FONT][FONT=Consolas][COLOR=#0000ff][FONT=Consolas][COLOR=#0000ff][FONT=Consolas][COLOR=#0000ff][SIZE=2]int[/SIZE][/COLOR][/FONT][/COLOR][/FONT][/COLOR][/FONT][FONT=Consolas][FONT=Consolas][SIZE=2][COLOR=#000000] main()[/COLOR][/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]CarType cars [10];[/SIZE]
[/FONT][/FONT][FONT=Consolas][COLOR=#0000ff][FONT=Consolas][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][/COLOR][/FONT][/COLOR][/FONT][FONT=Consolas][FONT=Consolas][SIZE=2] nb;[/SIZE]

[/FONT][/FONT]


بصراحه هرييت كل اللي اعرفه مادري صح او لا .... مع اني ما حضرت المحاضرات مال ال struct بس درستهم من النت .,,.:no::sad_1:

ساعدوني :tears::tears:


الكوود ما ينسخ عندي كامل مادري ليش :(
مسوي تحت فور لوب
 
شكللله ماميش احد >>>>> صفر يعني :(:tears::no::tears::RpS_crying:
 
  1. Add to the program of your previous lab a new struct called DateType with 3 members (day, month and year).


  1. Redefine the struct CarType to hold the following :

  1. seating capacity(int)
  2. price (float)
  3. received date(DateType)
  4. colors[10] array of colors (array of strings).
  5. Number of colors available.


b) Rewrite the following functions.

  1. Write a function that read one data of one car.
void readcar (CarType &X) {………..}


  1. Write a function that output the specifications of one car.
void outputcar (CarType X) {………..}

c)In the main function:
a. Declare an array named cars of the data type CarType.
b. Enter an integer NB for car number.
c. Reads data of NB cars.
c. Output specification of all cars received in October 2012.(10/2012)


طبعا انا حليت نصه تقريبا بس شيرت و ما عرفت التكمله


اخر شي مشير انا ....

لاهنتوو الحل :( :sad_1:
حليته وباقي اخر خطوه اله هي ان نسوي if condition حق ال day و ال month و ال year بس مو عارفه شلون اسويه بالضبط
HTML:
#include
<iostream>
#include
<string>
using
 namespace std;
struct
 datetype
{
    
int day;
	
int month;
	
int	year ;
};
struct
 cartype
{
int
 seatingcapacity;
float
 price;
datetype receiveddate;
string colors[10];
int
 noc;
};
 
void
 readcar( cartype & x)
{
cin>>x.seatingcapacity>>x.price>>x.receiveddate.day>>x.receiveddate.month>>x.receiveddate.year>>x.noc;
cout<<endl;
cout<<
"enter colors "<<endl;
for
 (int i=0;i<x.noc;i++)
{
	cin>>x.colors[i];
	cout<<endl;
}
}
 
void
 outputcar (cartype x) 
{
cout<<x.seatingcapacity<<
" "<<x.price<<" "<<x.receiveddate.day<<" "<<x.receiveddate.month<<" "<<x.receiveddate.year<<" "<<x.noc<<endl;
for
 (int i=0;i<x.noc;i++)
	cout<<x.colors[i]<<
" ";
cout<<endl;
}
int
 main()
{
cartype cars[10];
int
 nb;
cout<<
"enter cars number ";
cin>>nb;
cout<<endl;
 
 
 
 
 
كود:
[COLOR=#0000ff][COLOR=#0000ff][COLOR=#0000ff] [FONT=Consolas][SIZE=2]#include[/SIZE][/FONT][/COLOR][/COLOR][/COLOR][COLOR=#a31515][COLOR=#a31515][COLOR=#a31515][FONT=Consolas][SIZE=2]<string>[/SIZE][/FONT]
[/COLOR][/COLOR][/COLOR][COLOR=#0000ff][COLOR=#0000ff][COLOR=#0000ff][FONT=Consolas][SIZE=2]using[/SIZE][/FONT][/COLOR][/COLOR][/COLOR][SIZE=2][FONT=Consolas][COLOR=#0000ff][FONT=Consolas][COLOR=#0000ff][FONT=Consolas][COLOR=#0000ff]namespace[/COLOR][/FONT][/COLOR][/FONT][/COLOR][/FONT][FONT=Consolas][FONT=Consolas][COLOR=#000000] std;[/COLOR]
[/FONT][/FONT][/SIZE][FONT=Consolas][COLOR=#0000ff][FONT=Consolas][COLOR=#0000ff][FONT=Consolas][COLOR=#0000ff][SIZE=2]struct[/SIZE][/COLOR][/FONT][/COLOR][/FONT][/COLOR][/FONT][FONT=Consolas][FONT=Consolas][SIZE=2][COLOR=#000000] DateType[/COLOR][/SIZE]
[SIZE=2]{[/SIZE]
[/FONT][/FONT][FONT=Consolas][COLOR=#0000ff][FONT=Consolas][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][/COLOR][/FONT][/COLOR][/FONT][FONT=Consolas][FONT=Consolas][SIZE=2] day ,month year ;[/SIZE]
[SIZE=2]};[/SIZE]
[/FONT][/FONT][FONT=Consolas][COLOR=#0000ff][FONT=Consolas][COLOR=#0000ff][FONT=Consolas][COLOR=#0000ff][SIZE=2]struct[/SIZE][/COLOR][/FONT][/COLOR][/FONT][/COLOR][/FONT][FONT=Consolas][FONT=Consolas][SIZE=2][COLOR=#000000] cartype[/COLOR][/SIZE]
[SIZE=2]{[/SIZE]
[/FONT][/FONT][FONT=Consolas][COLOR=#0000ff][FONT=Consolas][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][/COLOR][/FONT][/COLOR][/FONT][FONT=Consolas][FONT=Consolas][SIZE=2] seatingcapacity;[/SIZE]
[/FONT][/FONT][FONT=Consolas][COLOR=#0000ff][FONT=Consolas][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]float[/COLOR][/SIZE][/FONT][/COLOR][/FONT][/COLOR][/FONT][FONT=Consolas][FONT=Consolas][SIZE=2] price;[/SIZE]
[SIZE=2]datetype receiveddate;[/SIZE]
[SIZE=2]string colors[10];[/SIZE]
[/FONT][/FONT][FONT=Consolas][COLOR=#0000ff][FONT=Consolas][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][/COLOR][/FONT][/COLOR][/FONT][FONT=Consolas][FONT=Consolas][SIZE=2] noc;[/SIZE]
[SIZE=2]};[/SIZE]
[/FONT][/FONT][FONT=Consolas][COLOR=#0000ff][FONT=Consolas][COLOR=#0000ff][FONT=Consolas][COLOR=#0000ff][SIZE=2]void[/SIZE][/COLOR][/FONT][/COLOR][/FONT][/COLOR][/FONT][FONT=Consolas][FONT=Consolas][SIZE=2][COLOR=#000000] readcar (CarType &X) [/COLOR][/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]cin>>cartype.seatingcapacity>>cartype.price>>cartype.datetype.receiveddate>>cartype.colors[10]>>cartype.noc;[/SIZE]
[SIZE=2]}[/SIZE]
[/FONT][/FONT][FONT=Consolas][COLOR=#0000ff][FONT=Consolas][COLOR=#0000ff][FONT=Consolas][COLOR=#0000ff][SIZE=2]void[/SIZE][/COLOR][/FONT][/COLOR][/FONT][/COLOR][/FONT][FONT=Consolas][FONT=Consolas][SIZE=2][COLOR=#000000] outputcar (CarType X) [/COLOR][/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]cout<<cartype.seatingcapacity<<cartype.price<<cartype.datetype.receiveddate<<cartype.colors[10]<<cartype.noc;[/SIZE]
[SIZE=2]}[/SIZE]
[/FONT][/FONT][FONT=Consolas][COLOR=#0000ff][FONT=Consolas][COLOR=#0000ff][FONT=Consolas][COLOR=#0000ff][SIZE=2]int[/SIZE][/COLOR][/FONT][/COLOR][/FONT][/COLOR][/FONT][FONT=Consolas][FONT=Consolas][SIZE=2][COLOR=#000000] main()[/COLOR][/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]CarType cars [10];[/SIZE]
[/FONT][/FONT][FONT=Consolas][COLOR=#0000ff][FONT=Consolas][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][/COLOR][/FONT][/COLOR][/FONT][FONT=Consolas][FONT=Consolas][SIZE=2] nb;[/SIZE]

[/FONT][/FONT]


بصراحه هرييت كل اللي اعرفه مادري صح او لا .... مع اني ما حضرت المحاضرات مال ال struct بس درستهم من النت .,,.:no::sad_1:

ساعدوني :tears::tears:


الكوود ما ينسخ عندي كامل مادري ليش :(
مسوي تحت فور لوب

تفضل .. :smile2:

كود:
#include <iostream>
#include <string>
using namespace std;
struct DateType
{
    int day ,month,year ;
};
struct CarType
{
    int seatingcapacity;
    float price;
    DateType receiveddate;
    string colors[10];
    int noc;
};
void readcar (CarType & x) 
{
    cout<<"Enter seating capacity : ";
    cin>>x.seatingcapacity;
    cout<<"Enter price : ";
    cin>>x.price;
    cout<<"Enter receiveddate day : ";
    cin>>x.receiveddate.day;
    cout<<"Enter receiveddate month : ";
    cin>>x.receiveddate.month;
    cout<<"Enter receiveddate year : ";
    cin>>x.receiveddate.year;
    cout<<"Enter number of colors available '<=10' : ";
    do{cin>>x.noc;}while(x.noc>=10);
    cout<<"Enter car colors : ";
    for (int i=0;i<x.noc;i++)
        cin>>x.colors[i];
    cout<<endl;
}
void outputcar (CarType x) 
{
    cout<<"Seating capacity : "<<x.seatingcapacity<<endl;
    cout<<"Price : "<<x.price<<endl;
    cout<<"Receiveddate day : "<<x.receiveddate.day<<endl;
    cout<<"Receiveddate month : "<<x.receiveddate.month<<endl;
    cout<<"Receiveddate year : "<<x.receiveddate.year<<endl;
    cout<<"Number of colors available : "<<x.noc<<endl;
    cout<<"Car colors : "<<endl;
    for (int i=0;i<x.noc;i++)
        cout<<x.colors[i]<<" ";
    cout<<endl<<endl;
}
int main()
{
    CarType cars [100];
    int nb;
    cout<<"Enter munber of cars : ";
    cin>>nb;
    cout<<"\nEnnter info of "<<nb<<" cars :\n\n";
    cout<<"         <-------------------------------------------->\n\n";
    for (int i=0;i<nb;i++)
    {
        cout<<"Car N.O"<<i+1<<" :\n\n";
        readcar(cars[i]);
    }
    cout<<"\n\n         <============================================>\n\n";
    cout<<"Cars received in October 2012 :\n\n";
    for (int i=0;i<nb;i++)
        if (cars[i].receiveddate.month==10 && cars[i].receiveddate.year==2012)
            outputcar(cars[i]);
    return 0;
}
 
حليته وباقي اخر خطوه اله هي ان نسوي if condition حق ال day و ال month و ال year بس مو عارفه شلون اسويه بالضبط

الشرط بسيط .. كأن نسوي " output " عادي لكن نخلي فيه شرط
كود:
if (cars[i].receiveddate.month==10 && cars[i].receiveddate.year==2012)
 
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. [*=left]Set and get functions for all the data members.
    [*=left] 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.
    [*=left]Deposit which is used to Deposit a certain amount Y into the Account. It should of course increase the Balance by Y.
    [*=left]IsAccountEmpty which returns true if the Balance is less than or equal to zero.
Otherwise it returns false.​


  1. [*=left]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. [*=left]Call function Set to set MyAccount with your name and account number and 100BD in balance.
    [*=left]Deposit 500BD in MyAccount
    [*=left]Print your account details
    [*=left]Withdraw 150BD from MyAccount
    [*=left]print your account details again.
 
عودة
أعلى أسفل