-
سؤالين C++
السلام عليكم
ممكن حد يساعدني في حل السؤالين
بواسطة loop و if ?
Exercise 2:
Write a C++ program to performing the following:
· Read a positive integer n from an input file called number.txt. Assume n is always an even number.
· Read n positive integers from the input file number.txt.
· Find the maximum of the first half of integers and the minimum of the last half of integers.
· Find the sum of all even numbers and the average of all odd numbers.
· All output should be directed to the screen monitor.
Sample input file: number.txt
10
23 12 45 13 67 18 14 98 89 35
Sample output
The maximum of the first half is: 67
The minimum of the second half is: 14
The sum of all even numbers is: 142
The average of all odd numbers is: 45.33
Exercise#3:
Write a program that finds students who score the highest and lowest average marks of the first two homework in CS (I). Your program should read the data from a file called "hw.txt" and displays the output to another file called “results.txt”. The first line of the input file contains the number of students, n. The next n lines contain information about each student. Each data line contains the student name (first name and last name) and his/her marks, each out of 30.
The output should display all student names, marks, and grades. In addition your program should calculate and display the highest and lowest marks along with the name of the student. Also, your program should calculate and display all the average and the grade of the entire class. (See sample input/output). Also, see table for assigning letter grades.
A
B
C
D
F
90-100
80-89
70-79
60-69
Less 60
If your input file contains:
20
Mohamed Al-Ayoubi 21 18
Hiba Ahmed 22 14
Abeer BentMoussa 24 26
Ahmed Akibah 20 28
Noura Al-Kaabi 23 20
Abdullah Al-Souyaidi 18 28
Khori Abdullah 28 29
Eman Al-Harriri 25 29
Hithem Abu-Falafel 20 27
Aishamel Muqabal 21 20
Mounir Al-Arabi 20 28
HudaAmel Al-Khamissi 21 13
Huda Al-Ourbani 23 23
Mohamed Al-Sheikh 25 29
Rawshan Al-Nawaz 20 28
Saifeddin Al-Hashmi 22 26
Mohamed Al-Kawtahri 26.5 21.5
Abdullah Al-Badilz 19 25
Ibrahim Al-Khaboussi 25 15
Allaa Al-Maliki 29 19
The output should look like:
Student Name Mark1 Mark2 Avg. Mark Grade
--------------------------------------------------------------------------------------------------------------------
Mohamed Al-Ayoubi 21.00 18.00 19.50 D
Hiba Ahmed 22.00 14.00 18.00 D
Abeer BentMoussa 24.00 26.00 25.00 B
…………. ….. ……. …….. …..
Allaa Al-Maliki 29.00 19.00 24.00 B
The Maximum average mark is: 28.50 Scored by : Khori Abdullah
The minimum average mark is: 17.00 Scored by : HudaAmel Al-Khamissi
The average of the class: 23.29
The Grade of the class: C
-
رد: سؤالين C++
سهلين البرامج حيييييل بس مادري اذا للحين تبي الجواب ولالا
ضوابط المشاركة
- لا تستطيع إضافة مواضيع جديدة
- لا تستطيع الرد على المواضيع
- لا تستطيع إرفاق ملفات
- لا تستطيع تعديل مشاركاتك
-
قوانين المنتدى