Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

A LEVEL 2 MODULE, AUTUMN SEMESTER 2021-2022

EEEE2063 Design and Implementation of Engineering Software

PRACTICE PAPER

Please develop all your code solutions as single .c or .cpp files, one for each part. Hence you will submit 5 .c/.cpp files in total all zipped together as one file.

Note Well: It is expected that you adopt good professional practice throughout even when not explicitly asked to. However, we must retain an acute awareness of the overall time budget for this activity and make judgements accordingly.

Part 1 (10%) : To allow you to demonstrate an appreciation of the professional context and how that influences the development of even simple non-object oriented programs.

Note for practice purpose  maybe two such smaller questions (parts 1& 2) or maybe a single larger question (i.e. just a part 1)

Scenario for part 1:

In encryption techniques a simple utility algorithm is the prefix scan. Given an input array of floating-point values, a, the output array, b, contains values such that

j=i

bi  = x aj

j=0

I.e “in human being words” the next output is the previous output + the next input

Examples:

Input data   a={7, 2, 3, 4}

Input data   a={1, -4, 9, 5, -2}

Output data b={7, 9, 12, 16}

Output data b={1, -3, 6, 11, 9}

Task: Write a C or C++ function that performs this operation and provide a suitable test main. Note well, no “user interface” is expected here.

Practice exam technique hint: If you just cant get you head around the maths of the task  remember this is a software module and assessed as such  clearly identify the required code structure, data types, function blocks, suitable comments, pre-empting errors   that will still earn a significant mark

Part 2 (10%) : To allow you to demonstrate an appreciation of the professional context and

how that influences the development of even simple non-object oriented programs. Task:

Write a C++ style function that accepts an array of chars as its argument and is to identify the largest and the smallest values contained within the array. Hint: Consider carefully, how do you propose to indicate to the caller the pair of answer values?

Part 3 (20%): To allow you to demonstrate the use of more sophisticated techniques for indicating and moving data around programs and particular C++ extensions.

Task: Please write a C++ program (using C++ memory and input/output techniques) that

  Asks a user to enter an integer and then dynamically creates an array of chars of that

size.

  Gives random values to the elements of the array using the full range of the char

representation. Below is a reference manual entry that may be useful.

  Calls the function you developed in Part 2 to identify the smallest and largest values in

the array and reports this on the screen.

  Releases the dynamic memory used for the array and terminates

Note that we do not know how to check that the memory allocation was successfully completed in C++ so you are not expected to test for that.

Warning be careful about cut & pasting code from pdfs embedding hidden characters

Reference for Part 3: Extracted verbatim from rand - C++ Reference (cplusplus.com)

rand

int rand (void);

Generate random number

Returns a pseudo-random integral number in the range between 0 and  RAND_MAX.

This number is generated by an algorithm that returns a sequence of apparently non-related numbers each time it is called. This algorithm uses a seed to generate the series, which       should be initialized to some distinctive value using function srand.

RAND_MAX is a constant defined in  <cstdlib>.

A typical way to generate trivial pseudo-random numbers in a determined range using rand is to use the modulo of the returned value by the range span and add the initial value of the     range:

v1 = rand() % 100;         // v1 in the range 0 to 99

v2 = rand() % 100 + 1;     // v2 in the range 1 to 100

v3 = rand() % 30 + 1985;   // v3 in the range 1985-2014

Notice though that this modulo operation does not generate uniformly distributed random   numbers in the span (since in most cases this operation makes lower numbers slightly more likely).

Part 4 (30%): To allow you to demonstrate the basics of declaring and defining the simple building blocks of object-oriented codes.

Scenario for parts 4 and 5:

A hotel wishes to have a basic software code for managing room bookings.

Overall, the software will maintain a list of room bookings.

Each room booking object will contain the following data;

  A room number,

  An unsigned integer customer number which identifies the person who has booked the

room

  A value for the cost per night in £

  The number of nights of the customer’s stay

I am your client (responsible for the larger software project) and am sub-contracting aspects of the code to you. Please complete them to my instructions as I am deliberately staging the work towards a final professional solution to progressively gain confidence in your capabilities.

Task: Create an object to encapsulate the concept of a room booking. In your (single .cpp) file you must clearly separate the declaration and definitions of the object.

Initially (i.e. just in this part 4), please make all member variables public and do not include any of the special member functions.

Task: Define and implement a member function for your room booking object that returns the total cost of the customer’s stay.

Task: Define and implement a member function for your room booking object that prints to the screen (in a single line format, suitable for the bill) all the information held and the total cost.

Task: Please provide a “main” that that proves that the above works as well as illustrates to potential other users of your object typical usage.

Part 5 (30%): To allow you to demonstrate the ability to define and declare professionally robust objects.

Re-design your room booking object from part 4 to the full professional standard we have   discussed in this module, equipping it with the minimum functionality expected of any well  designed class. In particular, it is required that after construction, the room number and the cost per night can neither be read nor changed except by member functions of the class.