Type: Group Assignment
(maximum number of group members is
2 people)
Weight: 5%
Exercises:
Q1. (25 marks) Write a C++ program that uses an array to store the grades of N students (N is entered by the user), and outputs the information below. Your program should be structured using functions. Each functionality should be implemented in a separate function.
- Maximum grade
- Minimum grade
- Average grade
- Median grade
- Number of A grades (grades more than 80)
- Number of B grades (grades between 70 and 80)
- Number of C grades (grades between 55 and 70)
- Number of D grades (grades between 40 and 55)
- Number of F grades (grades less than 40)
Q2. (25 marks) Write a user-defined function that takes an integer number and outputs the reverse of that number. Call the function twice in the main function and test your program with two 3-digits and 4-digits numbers.
Example of output:
Type an integer number: 345
Output: 543
Type an integer number: 3097
Output: 7903
Q3. (50 marks) We want to create a program that controls the movements of a robot in an array of size Initially, the robot is at position 0. The controller supports the following commands:
right (n): the robot moves n cells right
left (n): the object moves n cells left
reboot: the object comes back to cell 0
1 COEN 243 Winter 2021
Consider the following example:
^ |
0 1 2 3 4 5 6 7 8 9
The new array after executing the command right(5) will look like this:
^ |
0 1 2 3 4 5 6 7 8 9
The new array after executing the command left(3) will look like this:
^ |
0 1 2 3 4 5 6 7 8 9
The program takes commands from a user as shown in the following example:
Controller Menu:
- Right
- Left
- Display
- Reboot
- Show Array
- Exit
Command Display display the position of the robot in the array. Command Show Grid displays the array. Command Exit terminates the program.
Implement the controllers commands using functions. Add the necessarily checks to ensure that the robot does not go out of bounds. Your program should be structured using functions. For example, each command should be implemented in a separate function. (30 marks)
We want to add the following commands (20 marks):
- cancel (n): The program cancels the last n operations and returns the robot to the initial position
- replay (n): The program replays the last n operations that have been cancelled.
2
Reviews
There are no reviews yet.