” 辅导ELEC362程序、 写作C++PAPER CODE ………………..ELEC362……………PAGE….1……..OF …………..4……………………..CONTINUEDMOCK EXAM PAPER(Open book test)Application development with C++TIME ALLOWED: 3 HoursINSTRUCTIONS TO CANDIDATESThe numbers in the right hand Margin represent an approximate guide to the marks availablefor that question (or part of a question). Total marks available are 100.For all questions requiring a code, make sure the code is well commented as comments arepart of the total mark of the code.For all questions requiring a code, the code submitted in the answer sheet must be machinereadable (copy and paste the code into your answer sheet).Answer ALL Questions.PAPER CODE ………………..ELEC362……………PAGE….2……..OF …………..4……………………..CONTINUED1 a) Write a C++ programme that reads a sentence, input by the user and displays abreakdown of how many each letter in the English alphabets was repeated. Forexample, the sentence how are you will display:25a appeared 1 time/sb appeared 0 time/sc appeared 0 time/sd appeared 0 time/se appeared 1 time/sThe list continues for the 26 letters. You can assume the following simplificationsabout the input to the programme:-All letters are lower case.-No symbols or numbers will be in the sentence.- No error handling is required.b) Draw a flow chart of an algorithm you propose for a C++ programme used to booka flight ticket. The programme will be used by a travel agent to do the followingtasks (no code is required):10- List all passengers on a given flight.- Retrieve information of a Passenger.Total35PAPER CODE ………………..ELEC362……………PAGE….3……..OF …………..4……………………..CONTINUED2. a) Explain the process of generating an executable file from the source code files. 6b) Explain what friend functions are used for. 6c) Define what the destructor of a class is, give an example of what it can be used for(no code is required).4d) You are given the following code, specify whether the variables are allocated on staticor dynamic memory:int i{ }; 2int r=i; 2double Array[5]; 2char *letter{nullptr}; 2int *number= new int(0); 2vectordouble data; 2Total28PAPER CODE ………………..ELEC362……………PAGE….4……..OF …………..4……………………..END3. a) Explain the difference between a vector and a list? Give an example of a situationwhere a list is more suitable than a vector in a code. What is the main disadvantageof using a list over a vector? (No code is required).7b) From basic datatypes, create a class Sphere and a class Cube, which areused to describe geometrical shapes to be used in a CAD programme. Thefollowing code from the Main function will be run to test your code. Thecomment in every line explains the used function or operator, etc.30Cube Cube1; // Initialising a cube with side length of 1Sphere Sph1(5); // Initialising a sphere with radius 5Cube1.setSide(5); // changes the side length of Cube1 to 5cout The surface Area of Cube1 is Cube1.SurfArea() and thesurface area of Sph1 is Sph1.SurfArea() endl;// The function SurfArea() returns the surface area of the shapedouble TotVol = Cube1.Vol() + Sph1.Vol();// Adds the volumes of the shapes, the function Vol() gives the volumeof the shapecout The total volume is TotVol;The output of this code when it runs should be:The surface Area of Cube1 is 150 and the Surface Area of Sph1is 314.159The total Volume is 648.598No error handling is required. For simplicity you can define the entire codein a single file (header files are not Needed).Total37如有需要,请加QQ:99515681 或WX:codehelp
“
添加老师微信回复‘’官网 辅导‘’获取专业老师帮助,或点击联系老师1对1在线指导。