Query Setupper: Xpree K. Lee the Zcie#2128 <Email: xpreee@gmail.com>
[ C, Si, P, Fe, O, B, Cl ] Account Autumn Equatorial Tropic (19Sep2016) 【江涛之神伍字胥】
File Name: Cards_CQ10.doc
Cards: Club Queen & 10 => 20 points (Lunar Year Fire Monkey Month 8th Night 18th)
Q1. [ Bounds of CPU Bits within Biodata Processors ] Answer all the following questions:
(a) Explain what is exception handling. [6 marks]
(b) Write a C/C++ computer program to input one unsigned integer from the keyboard, then calculate the factorial value of the input integer using a function called factorial. For this program, exception handling service has to be prepared to detect and handle the overflow error of unsigned integer.
[Hint 1: In the C/C++ standard header file called LIMITS.H, there is an integral constant represented by UINT_MAX for value 4294967295 or 2^32 – 1.]
[Hint 2: Remember to include important comments to help debug and maintain the C/C++ source files.]
[18 marks]
(c) For the C/C++ computer program in Part (b), what is the normal number of files?
[1 mark]
[ Total Marks: 25 * Fame_Nand_Cash(2) ]
Q2. [ Linear Constant on Monetary Exchanges ] Answer all the following questions:
(a) Figure Q4a shows a main driver program to add two different monetary units, i.e. Malaysian Ringgit (MYR$) and Singaporean Dollar (SGD$), directly as in forex (foreign exchange) transaction in the client user’s source code.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// forex_MYR_SGD.cpp : Defines the entry point for the console application.
#include <iostream>
#include <string>
using namespace std;
#include "myr.h"
#include "sgd.h"
int main() {
MYR myr1( 60000 ), myr2( 300000 ), myr3(0), myr4(0), myr5(0);
SGD sgd1( 60000 ), sgd2( 300000 ), sgd3(0), sgd4(0), sgd5(0);
myr3 = myr1 + myr2;
sgd3 = sgd1 + sgd2;
myr4 = myr1 + sgd1;
sgd4 = sgd2 + myr2;
myr5 = myr1 + sgd2;
sgd5 = sgd1 + myr2;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Figure Q4a An example of main program source code
(b) Figure Q4b shows the execution output results on the monitor screen, when two different monetary units can be added directly in the client user’s source code.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*** FOREX between MYR$ & SGD$ ***
myr3 (= myr1 + myr2): MYR$360000
sgd3 (= sgd1 + sgd2): SGD$360000
myr4 (= myr1 + sgd1): MYR$210000
sgd4 (= sgd2 + myr2): SGD$420000
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Figure Q4b An example of main program output
(c) Write out the source codes of two C++ classes MYR and SGD, for their class definition files in the form of two separated interface file and implementation file. [20 marks]
(d) Hints given by the examiner cum originator are some C++ features shall be there, including:
i. C++ class(es), both single and plural;
ii. splitting of class definition file;
iii. operator overloading;
iv. C++ keyword called static;
v. C++ keyword called friend; and/or
vi. C++ standard header file called <string>.
(e) For forex, assume that a partnership of two to four national central banks succeeds to cooperate efficiently in the monetary and cash wars. Prior knowledge components given here are from the originator’s main program source code and examinee’s answering source codes.
It is clear that forex involving two currency units is still efficient in coding and timing. However, when the forex situations involve more legal entities, such like four-node partnership or four currencies, coding will for sure become complicated and inefficient in timing.
Forex states become even more complex when a partnership of central banks interacts with some external monetary units. An example given is when the partnership of Euro Dollars (EUR$) interacts with the US Dollars (USD$), China Renminbi (RMB$), and Japanese Yen (JPY$).
ANSWER REQUIRED: State and suggest some C++ feature(s) that can solve those above-mentioned complex forex situations.
[5 marks]
[ Total Marks: 25 * 名利各以半数计(2)倍 ]