[Solved] COEN 243 Assignment 3 UserDefined Functions/Arrays

$25

File Name: COEN_243__Assignment_3__UserDefined_Functions/Arrays.zip
File Size: 489.84 KB

SKU: [Solved] COEN 243 – Assignment 3 – User‐Defined Functions/Arrays Category: Tag:
5/5 - (1 vote)

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.

  1. Maximum grade
  2. Minimum grade
  3. Average grade
  4. Median grade
  5. Number of A grades (grades more than 80)
  6. Number of B grades (grades between 70 and 80)
  7. Number of C grades (grades between 55 and 70)
  8. Number of D grades (grades between 40 and 55)
  9. 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:

  1. Right
  2. Left
  3. Display
  4. Reboot
  5. Show Array
  6. 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.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] COEN 243 Assignment 3 UserDefined Functions/Arrays
$25