Eee2109 Final Question Fall 19 A B
Eee2109 Final Question Fall 19 A B
Page 1 of 6
Part-A
Time for Part-A: 2 hours + 1 hour for scanning and uploading Marks for Part-A: 40
There are 5 (five) questions in Part-A. Answer any 4 (four) questions.
Fill the top-page of the answer-script according to the provided template in the Google Form
(provided in the Google Class room).
1. a. Write the bubble sort in C++ with the following modifications. [05]
After the first round, the largest number is stored in the highest index of the array.
After the second round, the second-largest number is stored in the second-highest
index of the array. And it goes so on for the future rounds.
If the data in the array are already in the proper order, no shuffling is required. At
this point, the program shows the sorting.
Sample output:
Round 0: 2 4 6 8 10 12 68 45 37 89
Round 1: 2 4 6 8 10 12 45 37 68
Round 2: 2 4 6 8 10 12 37 45
b. Write and apply the following function in a C++ program to test the functionality. [05]
This function indirectly sorts (in descending order) the floats pointed to by the last n
pointers in the array a by rearranging the pointers:
2. a. Write and apply the function gunon() in a C++ program. You should use a random [05]
function to produce two positive one-digit integers. The function should then ask a
question, such as, "How much is 5 times 8?". The user types the answer. If the
answer is correct, the program prints “Sabaash!”, and continues to the next
multiplication question. If the answer is wrong, the program prints “Ekbar na parile
dekho shotobar.” and continues with the same multiplication question again
repeatedly until the user types the correct answer. For the termination of program
user should press -1
Sample output:
Enter -1 to End.
How much is 4 times 9 (-1 to End)? 36
Sabaash!
How much is 7 times 0 (-1 to End)? 0
Page 2 of 6
Sabaash!
How much is 7 times 8 (-1 to End)? 55
ekbar na parile dekho shotobar.
How much is 7 times 8 (-1 to End)? 56
Sabaash!
How much is 5 times 0 (-1 to End)? -1
Ajker moto ekhanei shesh.
Hints:
srand(time(0));
x = rand() % 10;
//they are under <cstdlib> and <ctime>
b. Write the following function and apply it in a C++ program. This function takes the [05]
time as three integer arguments (for hours, minutes and seconds), and returns the
number of seconds. Use the function shomoy (hh, mm, ss) to calculate the amount
of time in seconds between two times, both of which are within a 24-hour cycle of
the clock.
Sample output:
Enter the time as three integers[h m s]: 5 33 45
Enter another time as three integers[h m s]: 9 22 8
The difference between the times: 13703 seconds
3. a. Write and use the following function in a C++ program. This function changes the [05]
sign of each of the positive floats to negative pointed to by the last n pointers in the
array a:
void abcd(float* a[], int n)
A right triangle can have sides that are all integers. The three sides must satisfy the
relationship that the sum of the squares of two of the sides is equal to the square of
the hypotenuse. These sides are known as Pythagorean triples. Your program should
find all the Pythagorean triples for both sides and the hypotenuse, no larger than 500.
Use a triple-nested for-loop that tries all possibilities.
Sample output:
Side1 Side2 Hypotenuse
476 93 485
480 31 481
480 88 488
480 108 492
480 140 500
483 44 485
... ... ...
... ... ...
A total of 772 triples were found.
4. Convert the following idea of keeping track of the players into a C++ program. [10]
The program should keep the profile and perform statistical analysis for a cricket
Page 3 of 6
team of maximum 30 players. The profile of each player contains the player's
number, name, number of matches played, district, age, runs, boundaries, bowling
over, wickets. The program will prompt the user to choose the operations of the
player profile from a menu as shown below:
============================
Player Performance Analyzer
============================
1. Add player profile
2. Delete player profile
3. Update player profile
4. View all player profile
5. Calculate an average runs and wickets for a selected player
6. Show the best batsman depending on the average runs
7. Show the best bowler depending on the average wickets
8. Sort players on the batting and bowling average
5. Convert the following idea into a complete C++ program using a Stack class for a [10]
deck of 52 playing cards. The program includes a default constructor, a destructor,
and usual stack operations, such as, push(), pop(), isEmpty(), and isFull(). Use
an array implementation of the class. Use necessary pointers to traverse the array and
keep record of the current card drawing position.
Page 4 of 6
Part-B
Submission Deadline for Part-B: 30/10/2020 by 6:30 PM. Marks for Part B: 20
There are 2 (Two) questions in Part-B. All questions must be answered.
Fill the top-page of the answer-script according to the provided template in the Google Form
(provided in the Google Class room).
1. You are appointed as the programmer of the AUST Education System (AES). Using the [10]
AES, a user can add, display, and edit the student information, teacher information as
well as notices of AUST. The program must have an easy to use menu system as well as
a navigation system. A user must have the ability of returning to the main menu from
any part of the program. Also, the program must display appropriate error messages, in
case the user applies any invalid value/command.
============================
AUST Education System (AES)
============================
---Display information
------Student information
------------All students,
------------Find a student by the first name,
------------Find a student by the last name
------Teacher information
------------All teachers,
------------Find a teacher by the first name,
------------Find a teacher by the last name
------Noticeboard
------------Show all notices
------------Show the latest notice
---Edit information
------Edit student's information
------Edit teacher's information
Page 5 of 6
------Edit notice
Write a C++ code for the AES. While writing the code in C++, you must specify the
task of each block/function/variable with appropriate comments for a clear
understanding.
2. As the programmer of the AES (from the Question 1), you are instructed to add new [10]
features. The new features will give a user the ability to add, display, and edit student's
academic record. This will act as an extension of the student information of the AES
(from the Question 1). The program must have an easy to use menu system as well as
navigation system. A user must have the ability of returning to the main menu from any
part of the program. Also, the program must display appropriate error messages, in case
the user apply any invalid value/command.
---Edit records
------Edit subjects
------Edit marks in each subject
Write a C++ code for this extended AES feature. While writing the code in C++, you
must specify the task of each block/function/variable with appropriate comments for a
clear understanding.
Page 6 of 6