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

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

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

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

write a program to read 10 names from file "names.dat" and print thier name length to file " namelength.dat".
In addition print the maximum and minimum length on screen

PHP:
 #include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main()
{
string str;
int x=10 , y=10;
ifstream in;in.open("names.dat");
ofstream out;out.open(" namelength.dat");
if (!in)
{
cout<<"Sorry No File";
return 1;
}
while(!in.eof())
{
getline(in,str);
out<<str.length()<<endl;
if (str.length()>x)
x=str.length();
else if (str.length()<y)
y=str.length();
}
cout<<"Maxmum name size : "<<x<<endl;
cout<<endl;
cout<<"Maimum name size : "<<y<<endl;
system("pause");
return 0;
}
وش الخطأ البرنامج موراضي يشتغل
:RpS_crying:
​

إحتمال مافي الملف اللي يقرأ منه المعلومات .. :nosweat:
 
ايييي صح ماسويت الملف :RpS_ohmy::blushing:
وناسية الطريقة .. شلون اسويه؟

ves03.png
 
[TABLE="align: right"]
[TR]
[TD]
[/TD]
[/TR]
[/TABLE]

Part#1: Lab Exercise

Write a C++ program that includes the following functions:

1. A function named sortList that takes as parameters: an array of double and the array size. The function should sort the numbers in a descending order. Use selection sort algorithm.

2. A function named readList that takes as parameters: an array of double and the array size. The function should prompt the user to input the array data.

3. A function named printList that takes as parameters: an array of double and the array size. The function should display the elements of the array.

4. A function named print topFive that takes as parameters: an array of double and the array size. The function should print the largest five numbers in the array. Hint: you have to sort the array first.


Write a main program that prompts the user to enter his ID, name and 10 double numbers representing his quiz grades of ITCS104. Using the above functions, the program should generate a report as follow:


[TABLE="align: center"]
[TR]
[TD]Sample Input/Output:
[/TD]
[/TR]
[TR]
[TD]
Enter Student ID: 20081234
Enter Student Name: Student1
Enter quiz grades: 1.5 2.5 6.5 4.5 10 9 8 7 3.5 5.5

Report
ID: 20081234
Name: Student1
Grades (descending): 10 9 8 7 6.5 5.5 4.5 3.5 2.5 1.5
Top 5 grades: 10 9 8 7 6.5

[/TD]
[/TR]
[/TABLE]







Part#2: Home Assignment

Complete the previous exercise to include the following functions:

1. A function named computeAverage that takes as parameters: an array of double and the array size. The function should calculate and return the average of the double numbers in the array.

2. A function named displayAboveAverage that takes as parameters: an array of double and the array size. The function should display the numbers in the array that are above the average. Hint: call computeAverage to find the average of the numbers.

3. A function named countGrade that takes as parameters: an array of double, the array size, a double value (oldValue), and a double value (newValue). The function should replace each occurrence of the oldValue by the newValue.

Write a main program to test your functions.




ممكن فقط شرح طريقة السؤال؟؟!!
 
[TABLE="align: right"]
[TR]
[TD]
[/TD]
[/TR]
[/TABLE]

Part#1: Lab Exercise

Write a C++ program that includes the following functions:

1. A function named sortList that takes as parameters: an array of double and the array size. The function should sort the numbers in a descending order. Use selection sort algorithm.

2. A function named readList that takes as parameters: an array of double and the array size. The function should prompt the user to input the array data.

3. A function named printList that takes as parameters: an array of double and the array size. The function should display the elements of the array.

4. A function named print topFive that takes as parameters: an array of double and the array size. The function should print the largest five numbers in the array. Hint: you have to sort the array first.


Write a main program that prompts the user to enter his ID, name and 10 double numbers representing his quiz grades of ITCS104. Using the above functions, the program should generate a report as follow:


[TABLE="align: center"]
[TR]
[TD]Sample Input/Output:
[/TD]
[/TR]
[TR]
[TD]
Enter Student ID: 20081234
Enter Student Name: Student1
Enter quiz grades: 1.5 2.5 6.5 4.5 10 9 8 7 3.5 5.5

Report
ID: 20081234
Name: Student1
Grades (descending): 10 9 8 7 6.5 5.5 4.5 3.5 2.5 1.5
Top 5 grades: 10 9 8 7 6.5

[/TD]
[/TR]
[/TABLE]







Part#2: Home Assignment

Complete the previous exercise to include the following functions:

1. A function named computeAverage that takes as parameters: an array of double and the array size. The function should calculate and return the average of the double numbers in the array.

2. A function named displayAboveAverage that takes as parameters: an array of double and the array size. The function should display the numbers in the array that are above the average. Hint: call computeAverage to find the average of the numbers.

3. A function named countGrade that takes as parameters: an array of double, the array size, a double value (oldValue), and a double value (newValue). The function should replace each occurrence of the oldValue by the newValue.

Write a main program to test your functions.




ممكن فقط شرح طريقة السؤال؟؟!!

Write a C++ program that includes the following functions:

1. A function named sortList that takes as parameters: an array of double and the array size. The function should sort the numbers in a descending order. Use selection sort algorithm.

نسوي فنكشن sortlist تاخذ باراميتر ( أرري نوعها double ، السايز مال الأرري نوعه int ) الفنكشن لازم ترتب العناصر تنازليا من الأكبر للاصغر باستخدام selection sort method

2. A function named readList that takes as parameters: an array of double and the array size. The function should prompt the user to input the array data.

نسوي فنكشن تطلب من اليوزر

3. A function named printList that takes as parameters: an array of double and the array size. The function should display the elements of the array.أن يدخل بيانات للأرري ، يعني كلما يدخل رقم نخزنه في بوزيشن ونروح للبوزيشن اللي بعده ..

4. A function named print topFive that takes as parameters: an array of double and the array size. The function should print the largest five numbers in the array. Hint: you have to sort the array first.

فنكشن تطبع أول أكبر 5 أرقام في الأرري ، بس قبل لازم نرتبهم تصاعديا او تنازليا ، لو رتبناهم تصاعديا راح نبدي من الأخير ونرجع بالبوزيشن 4 مرات فقط
اما اذا كان تنازلي الترتيب فنقدر نبدأ من البداية ونطبع أول 5 فقط ، لاحظي أن عندنا فنكشن sortlist تسوي هالشغلة فنسوي ليها كول هني اول تالي نطبع أول 5

Write a main program that prompts the user to enter his ID, name and 10 double numbers representing his quiz grades of ITCS104. Using the above functions, the program should generate a report as follow:

نطلب من اليوزر في المين يدخل لينا ID , name و 10 أرقام من نوع double يعبرون عن درجات كويزاته في مقرر ITCS104
بإستخدام هالمعلومات ، البرنامج لازم يطلع output بهالشكل :

Sample Input/Output:
Enter Student ID: 20081234
Enter Student Name: Student1
Enter quiz grades: 1.5 2.5 6.5 4.5 10 9 8 7 3.5 5.5

Report
ID: 20081234
Name: Student1
Grades (descending): 10 9 8 7 6.5 5.5 4.5 3.5 2.5 1.5
Top 5 grades: 10 9 8 7 6.5







Part#2: Home Assignment

Complete the previous exercise to include the following functions:

1. A function named computeAverage that takes as parameters: an array of double and the array size. The function should calculate and return the average of the double numbers in the array.

نسوي فنكشن تطلع لينا الأفرج مال الدرجات في الأرري

2. A function named displayAboveAverage that takes as parameters: an array of double and the array size. The function should display the numbers in the array that are above the average. Hint: call computeAverage to find the average of the numbers.

نسوي فنكشن تطبع لينا الدرجات اللي أعلى من الأفرج ، يعني اول لازم نسوي call للفنكشن القبلية عشان نحسب الأفرج بعدين نجيك اذا الدرجاة أكبر من الأفرج نطبعها

3. A function named countGrade that takes as parameters: an array of double, the array size, a double value (oldValue), and a double value (newValue). The function should replace each occurrence of the oldValue by the newValue.

نسوي فنكشن تستقبل 2 باراميتر ( درجة قديمة ، درجة جديدة ) نوعهم double
الفنكشن لازم تبحث عن الدرجة القديمة في الأرري ، واذا حصلتها تاخذ الدرجة الجديدة وتحطها مكانها .. مثل الـ makeup quiz يعني

Write a main program to test your functions.

سوي مين تختبرين فيه كل الفنكشنز اللي سويتينهم ..
 
السلام عليكم..
بالنسبه للاسايمنت لازم نكتبه ع برنامج ونبعثه ع البلاك بورد ولا بس نكتب طريقه البرنامج؟؟
:tears:ياريت تردو علي ضروري.. وشكرا
 
السلام عليكم..
بالنسبه للاسايمنت لازم نكتبه ع برنامج ونبعثه ع البلاك بورد ولا بس نكتب طريقه البرنامج؟؟
:tears:ياريت تردو علي ضروري.. وشكرا
تكتبين البرنامج و تطرشين ملف البرنامج عن طريق البلاك بورد

​
 
كود:
[LEFT]#include<iostream>
using namespace std;
void computeAverage(double arr[],double x, int size,double avg,double sum)
{
    avg=sum\size*1.0;
    cout<<"the avareg ="<<avg<<endl;
}
void displayAboveAverage(double arr[],double avg,int size)
{
    double indexavg;
    for (int i=0;i<size;i++)
        if(arr[i]>avg )
        {
            indexavg=avg;
        }
}
void countGrade(double oldvalue,double newvalue,double arr1[],double size1)
{
    for (int i=0;i<size;i++)
        if(arr1[i]>avg)
        {
            oldvalue=i;
            newvalue=arr1[i];
        }
}


void main ()
{
    double q1,q2,q3,q4,q5,q6,q7,q8,q9,q10, avg;
    long stid;
    string name;
    cout<<"enter student ID :"<<stid<<endl;
    cin>>stid;
    cout<<"enter student name :"<<name<<endl;
    cin>>name;
    cout<<"enter quiz grades:"<<endl;
    cin>>q1>>q2>>q3>>q4>>q5>>q6>>q7>>q8>>q9>>q10;
}

[/LEFT]



هاي بارت 2 :/ :( يطلع ايروورز ...!
 
كود:
[LEFT]#include<iostream>
using namespace std;
void computeAverage(double arr[],double x, int size,double avg,double sum)
{
    avg=sum\size*1.0;
    cout<<"the avareg ="<<avg<<endl;
}
void displayAboveAverage(double arr[],double avg,int size)
{
    double indexavg;
    for (int i=0;i<size;i++)
        if(arr[i]>avg )
        {
            indexavg=avg;
        }
}
void countGrade(double oldvalue,double newvalue,double arr1[],double size1)
{
    for (int i=0;i<size;i++)
        if(arr1[i]>avg)
        {
            oldvalue=i;
            newvalue=arr1[i];
        }
}


void main ()
{
    double q1,q2,q3,q4,q5,q6,q7,q8,q9,q10, avg;
    long stid;
    string name;
    cout<<"enter student ID :"<<stid<<endl;
    cin>>stid;
    cout<<"enter student name :"<<name<<endl;
    cin>>name;
    cout<<"enter quiz grades:"<<endl;
    cin>>q1>>q2>>q3>>q4>>q5>>q6>>q7>>q8>>q9>>q10;
}

[/LEFT]



هاي بارت 2 :/ :( يطلع ايروورز ...!

الأفضل تعريف مصفوفة في البرنامج بدل عدة متغيرات
 
مو موجدود عندي الخيار utility لما افتح فايل .

بس موجود
utility
code
program shhets
 

تحفظون الملف و تشغلون الكود إلا كتبتونه بالبرنامج ... و إذا الكود صح ، بيخرج ملف ثاني فيه عدد الحروف لكل كلمة

​


احنا عنا ملفين .. واحد لل INPUT والتاني لل OUTPUT ??
كيف بدي اعمل الملف التاني؟؟
 
احنا عنا ملفين .. واحد لل INPUT والتاني لل OUTPUT ??
كيف بدي اعمل الملف التاني؟؟
طبعًا تعملون ملف الـ input بأسم الملف إلا بالكود و تكتبون في داخله 10 أسماء وهميه (أي أسم و تحفظون الملف)
و بعد ما تشغلون البرنامج ، البرنامج بيفتح ملف الـ input و بيخرج ملف الـ output

بس ممكن تحطون الكود هني ، بشوفه إليكم علشان أقول إليكم ويش الخطوات بالضبط ...
​
 
in the programe for the file
ifstream in;in.open("names.dat");
ofstream out;out.open("namelength.dat");
if (!in)
 
عودة
أعلى أسفل