-Simple basic problem solving with C++ on menu driven programs using structural programming.
-Problem One:
-Write a C++ program that takes 2 numbers forming a range then accordingly
-Your program should contain and display a selection menu as follows:
(1)- Get all Even numbers within the range
(2)- Get all odd numbers within the range
(3)- Get the sum of the numbers within the range
(4)- Get all prime numbers within the range
(5)- Get maximum prime number within the range
(6)- Get maximum non-prime number within the range
(7)- Get total number of non-prime numbers within the range
(8)- Enter new range
(E)- Exit program
a. The program should be in a continuous state of running unless you choose (E) then your program should exit.
b. Every choice should be programmed as a separate function
c. Your program should handle the inputs start and end of range as following:
-
If range start number is 1 and end range number is 5 the range will be : 1,2,3,4,5
-
If range start number is 5 and end range number is 1 the range will be : 1,2,3,4,5
-Problem two:
-Having a 1D array of student names (at least 5), 1D of course names (at least 3), and 2D array of student’s grades in each course. Write the following functions, the menu for choosing one of the following should be looped.
1- Calculate and display the average GPA for each student along with the student’s name.
-Use the grade scheme (90+ grade = 4.0 GPA), (80+ = 3.5), (70+ = 3), (60+ = 2.5), (50+ = 2), (50- = 0).
2- Display the student with the highest grade in each course.
3- Display the student with the lowest grade in each course.
4- Display the average grade in each course.
5- Display students and their grades in all courses (Each line should include one student and all his grades, display it as a table).
6- Display Course names.
7- Display Student names.
8- Modify a student’s grade in a course.
9- Modify a course name.
10- Sort the students (and their grades) alphabetically (note that you have to swap grade positions when swapping student positions).
-Running & Output Example:
1 -Calculate and display the average GPA for each student.
2 -Display the student with the highest grade in each course.
3 -Display the student with the lowest grade in each course.
4 -Display the average grade in each course.
5 -Display students and their grades in all courses.
6 -Display Course names.
7 -Display Student names.
8 -Modify a student’s grade in a course.
9 -Modify a course name.
10-Sort the students (and their grades) alphabetically.
11-Exit.
5
Student grade list:
Student Name Course-1 Course-2 Course-3
Student-4 70.50 68.25 56.00
Student-3 95.00 98.75 90.00
Student-5 50.00 39.00 60.00
Student-2 80.25 82.00 87.00
Student-1 90.00 95.00 97.00
1 -Calculate and display the average GPA for each student.
2 -Display the student with the highest grade in each course.
3 -Display the student with the lowest grade in each course.
4 -Display the average grade in each course.
5 -Display students and their grades in all courses.
6 -Display Course names.
7 -Display Student names.
8 -Modify a student’s grade in a course.
9 -Modify a course name.
10-Sort the students (and their grades) alphabetically.
11-Exit.
1
Students average GPA list:
Student Name Student GPA (4.00)
Student-4 2.50
Student-3 4.00
Student-5 1.50
Student-2 3.50
Student-1 4.00
1 -Calculate and display the average GPA for each student.
2 -Display the student with the highest grade in each course.
3 -Display the student with the lowest grade in each course.
4 -Display the average grade in each course.
5 -Display students and their grades in all courses.
6 -Display Course names.
7 -Display Student names.
8 -Modify a student’s grade in a course.
9 -Modify a course name.
10-Sort the students (and their grades) alphabetically.
11-Exit.
2
Course max grade list:
Course Name Student Name Student Grade
Course-1 Student-3 95.00
Course-2 Student-3 98.75
Course-3 Student-1 97.00
1 -Calculate and display the average GPA for each student.
2 -Display the student with the highest grade in each course.
3 -Display the student with the lowest grade in each course.
4 -Display the average grade in each course.
5 -Display students and their grades in all courses.
6 -Display Course names.
7 -Display Student names.
8 -Modify a student’s grade in a course.
9 -Modify a course name.
10-Sort the students (and their grades) alphabetically.
11-Exit.
3
Course min grade list:
Course Name Student Name Student Grade
Course-1 Student-5 50.00
Course-2 Student-5 39.00
Course-3 Student-4 56.00
1 -Calculate and display the average GPA for each student.
2 -Display the student with the highest grade in each course.
3 -Display the student with the lowest grade in each course.
4 -Display the average grade in each course.
5 -Display students and their grades in all courses.
6 -Display Course names.
7 -Display Student names.
8 -Modify a student’s grade in a course.
9 -Modify a course name.
10-Sort the students (and their grades) alphabetically.
11-Exit.
4
Course average grade list:
Course Name Average Grade
Course-1 77.15
Course-2 76.60
Course-3 78.00
1 -Calculate and display the average GPA for each student.
2 -Display the student with the highest grade in each course.
3 -Display the student with the lowest grade in each course.
4 -Display the average grade in each course.
5 -Display students and their grades in all courses.
6 -Display Course names.
7 -Display Student names.
8 -Modify a student’s grade in a course.
9 -Modify a course name.
10-Sort the students (and their grades) alphabetically.
11-Exit.
5
Student grade list:
Student Name Course-1 Course-2 Course-3
Student-4 70.50 68.25 56.00
Student-3 95.00 98.75 90.00
Student-5 50.00 39.00 60.00
Student-2 80.25 82.00 87.00
Student-1 90.00 95.00 97.00
1 -Calculate and display the average GPA for each student.
2 -Display the student with the highest grade in each course.
3 -Display the student with the lowest grade in each course.
4 -Display the average grade in each course.
5 -Display students and their grades in all courses.
6 -Display Course names.
7 -Display Student names.
8 -Modify a student’s grade in a course.
9 -Modify a course name.
10-Sort the students (and their grades) alphabetically.
11-Exit.
6
Course list:
Course-1
Course-2
Course-3
1 -Calculate and display the average GPA for each student.
2 -Display the student with the highest grade in each course.
3 -Display the student with the lowest grade in each course.
4 -Display the average grade in each course.
5 -Display students and their grades in all courses.
6 -Display Course names.
7 -Display Student names.
8 -Modify a student’s grade in a course.
9 -Modify a course name.
10-Sort the students (and their grades) alphabetically.
11-Exit.
7
Student list:
Student-4
Student-3
Student-5
Student-2
Student-1
1 -Calculate and display the average GPA for each student.
2 -Display the student with the highest grade in each course.
3 -Display the student with the lowest grade in each course.
4 -Display the average grade in each course.
5 -Display students and their grades in all courses.
6 -Display Course names.
7 -Display Student names.
8 -Modify a student’s grade in a course.
9 -Modify a course name.
10-Sort the students (and their grades) alphabetically.
11-Exit.
8
Modify student grade:
Student name: Student
Student name entered not found !!
1 -Calculate and display the average GPA for each student.
2 -Display the student with the highest grade in each course.
3 -Display the student with the lowest grade in each course.
4 -Display the average grade in each course.
5 -Display students and their grades in all courses.
6 -Display Course names.
7 -Display Student names.
8 -Modify a student’s grade in a course.
9 -Modify a course name.
10-Sort the students (and their grades) alphabetically.
11-Exit.
8
Modify student grade:
Student name: Student-1
Course name: Course
Course name entered not found !!
1 -Calculate and display the average GPA for each student.
2 -Display the student with the highest grade in each course.
3 -Display the student with the lowest grade in each course.
4 -Display the average grade in each course.
5 -Display students and their grades in all courses.
6 -Display Course names.
7 -Display Student names.
8 -Modify a student’s grade in a course.
9 -Modify a course name.
10-Sort the students (and their grades) alphabetically.
11-Exit.
8
Modify student grade:
Student name: Student-1
Course name: Course-1
Selected student 'Student-1' course 'Course-1' current grade '90.00'
New grade: 1000.00
Invalid grade entered !!
1 -Calculate and display the average GPA for each student.
2 -Display the student with the highest grade in each course.
3 -Display the student with the lowest grade in each course.
4 -Display the average grade in each course.
5 -Display students and their grades in all courses.
6 -Display Course names.
7 -Display Student names.
8 -Modify a student’s grade in a course.
9 -Modify a course name.
10-Sort the students (and their grades) alphabetically.
11-Exit.
8
Modify student grade:
Student name: Student-1
Course name: Course-1
Selected student 'Student-1' course 'Course-1' current grade '90.00'
New grade: -90.00
Invalid grade entered !!
1 -Calculate and display the average GPA for each student.
2 -Display the student with the highest grade in each course.
3 -Display the student with the lowest grade in each course.
4 -Display the average grade in each course.
5 -Display students and their grades in all courses.
6 -Display Course names.
7 -Display Student names.
8 -Modify a student’s grade in a course.
9 -Modify a course name.
10-Sort the students (and their grades) alphabetically.
11-Exit.
8
Modify student grade:
Student name: Student-1
Course name: Course-1
Selected student 'Student-1' course 'Course-1' current grade '90.00'
New grade: 80.00
Updated
1 -Calculate and display the average GPA for each student.
2 -Display the student with the highest grade in each course.
3 -Display the student with the lowest grade in each course.
4 -Display the average grade in each course.
5 -Display students and their grades in all courses.
6 -Display Course names.
7 -Display Student names.
8 -Modify a student’s grade in a course.
9 -Modify a course name.
10-Sort the students (and their grades) alphabetically.
11-Exit.
5
Student grade list:
Student Name Course-1 Course-2 Course-3
Student-4 70.50 68.25 56.00
Student-3 95.00 98.75 90.00
Student-5 50.00 39.00 60.00
Student-2 80.25 82.00 87.00
Student-1 80.00 95.00 97.00
1 -Calculate and display the average GPA for each student.
2 -Display the student with the highest grade in each course.
3 -Display the student with the lowest grade in each course.
4 -Display the average grade in each course.
5 -Display students and their grades in all courses.
6 -Display Course names.
7 -Display Student names.
8 -Modify a student’s grade in a course.
9 -Modify a course name.
10-Sort the students (and their grades) alphabetically.
11-Exit.
9
Modify course name:
Course name: Course
Course name entered not found !!
1 -Calculate and display the average GPA for each student.
2 -Display the student with the highest grade in each course.
3 -Display the student with the lowest grade in each course.
4 -Display the average grade in each course.
5 -Display students and their grades in all courses.
6 -Display Course names.
7 -Display Student names.
8 -Modify a student’s grade in a course.
9 -Modify a course name.
10-Sort the students (and their grades) alphabetically.
11-Exit.
9
Modify course name:
Course name: Course-1
New course name: Course-new
Updated
1 -Calculate and display the average GPA for each student.
2 -Display the student with the highest grade in each course.
3 -Display the student with the lowest grade in each course.
4 -Display the average grade in each course.
5 -Display students and their grades in all courses.
6 -Display Course names.
7 -Display Student names.
8 -Modify a student’s grade in a course.
9 -Modify a course name.
10-Sort the students (and their grades) alphabetically.
11-Exit.
5
Student grade list:
Student Name Course-new Course-2 Course-3
Student-4 70.50 68.25 56.00
Student-3 95.00 98.75 90.00
Student-5 50.00 39.00 60.00
Student-2 80.25 82.00 87.00
Student-1 80.00 95.00 97.00
1 -Calculate and display the average GPA for each student.
2 -Display the student with the highest grade in each course.
3 -Display the student with the lowest grade in each course.
4 -Display the average grade in each course.
5 -Display students and their grades in all courses.
6 -Display Course names.
7 -Display Student names.
8 -Modify a student’s grade in a course.
9 -Modify a course name.
10-Sort the students (and their grades) alphabetically.
11-Exit.
10
Sort students by name:
Student-1
Student-2
Student-3
Student-4
Student-5
1 -Calculate and display the average GPA for each student.
2 -Display the student with the highest grade in each course.
3 -Display the student with the lowest grade in each course.
4 -Display the average grade in each course.
5 -Display students and their grades in all courses.
6 -Display Course names.
7 -Display Student names.
8 -Modify a student’s grade in a course.
9 -Modify a course name.
10-Sort the students (and their grades) alphabetically.
11-Exit.
5
Student grade list:
Student Name Course-new Course-2 Course-3
Student-1 80.00 95.00 97.00
Student-2 80.25 82.00 87.00
Student-3 95.00 98.75 90.00
Student-4 70.50 68.25 56.00
Student-5 50.00 39.00 60.00
1 -Calculate and display the average GPA for each student.
2 -Display the student with the highest grade in each course.
3 -Display the student with the lowest grade in each course.
4 -Display the average grade in each course.
5 -Display students and their grades in all courses.
6 -Display Course names.
7 -Display Student names.
8 -Modify a student’s grade in a course.
9 -Modify a course name.
10-Sort the students (and their grades) alphabetically.
11-Exit.
11