C/C++ 编程代写
当前位置:以往案例 > >案例CS C++ Programming and Software Engineeri
2017-09-28




(MUST be submitted through ICE so that the TAs can run your programs during marking.) Make sure your name and ID are printed on the cover page of your report.



Assessment Overview


This assessment aims at testing some basic concepts of C++ programming and initiates the routine of code development using the software development process (SDP), namely the five main steps of the software development process:

1. Problem statement: formulate the problem.


2. Analysis: determine the inputs, outputs, variables, etc


3. Design: define the list of steps (the algorithm) needed to solve the problem.


4. Implementation: the C++ code has to be submitted as a separate file. Just indicate here the name of the file.


5. Testing: explain how you have tested and verified your C++ program.


You will need to apply this methodology to each one of the following simple exercises.


What should be submitted?


A short report (up to a few pages of texts plus C++ source codes) detailing for all the questions of the project. The answer for each question should follow the SDP method:


a) SDP steps 1 to 3. (30% of the total marks for that question)


b) SDP step 4 (implementation): your C++ source code including the comments. (50%)


c) SDP step 5 (testing): you will explain how you have tested the correctness of your C++ program and will include some sample runs of your C++ Programs. (20%).


Testing result must be shown by screenshot.


The report in either Microsoft Word format (.DOCX file) or PDF format together with C source code for all questions should be zipped into a single file. (For maintenance purposes, it is always a good practice to comment your code as you go. The comments state the aim of the program, what are the inputs, what are the outputs, which algorithm is used, who is the author and so on.)



EEE102 Fundamental of C++ Assessment 1




EXERCISE 1 (5 POINTS OUT OF 15)


Write a function


bool same_vec (vectora, vectorb)


that checks whether two vectors have the same elements, ignoring the order and multiplicities. For ple, the two vectors {1, 4, 9, 16, 9, 7, 4, 9, 11} and {11, 11, 7, 9, 16, 4, 1} would be considered identical.


Requirements:


1. Vectors are inputted from keyboard and delimiter can be anything other than numbers.


2. The vector length is unknown and determined by the press of the Return key.


3. Solve this problem by using two different algorithms



EXERCISE 2 (10 POINTS OUT OF 15)


Design a new class to represent a fraction (a ration of two integer values).



The data members of the class Fraction are two integers top and bottom, denoting the numerator and denominator, respectively.

1 class Fraction


2 {


3 private:


4

int top;

// Numerator

5

int bottom;

// Denominator

6

public:

7 . . . . . .


8 };


Part 1: Fundamental requirements for the class Fraction.


1. Fractional numbers can be declared with both a numerator and denominator, or simple numerator:


Fraction a; // represents 0/1


Fraction b(3,4); // represents 3/4


Fraction c(5); // represents 5/1


2. Fractions should be able to act just like other numbers. Add, subtract, multiple and divide;


Compare based on values; Input and output.



Part 2: Advanced requirements


3. Fractional number is normalized to ensure that only the numerator can be negative and the value is in least common denominator form:


2/-3 would be converted into -2/3 automatically; 15/21 would be converted into 5/7 automatically.


4. Write methods to convert between decimals and fractions.



在线提交订单