关于算法:EN3085-Assessed

41次阅读

共计 6700 个字符,预计需要花费 17 分钟才能阅读完成。

EN3085 Assessed Coursework 1
The purpose of this coursework is to design a class that will allow programmers to manipulate univariate quadratic functions. These functions can be represented by three parameters in three different forms:
-A Standard form: f(x) = a x2 + b x + c, where a, b, and c are real numbers.
-A Factored form: f(x) = a (x – R1)(x – R2), where a is a real number and R1 and R2, the roots of the quadratic function (solutions of f(x)=0), can be either real or complex numbers.
-A Vertex form: f(x) = a (x – h)2 + k, where the vertex coordinates h and k are real numbers.
1.Create a class QuadraticF to represent univariate quadratic functions. [5]
An object of that class should:0
a)Store a univariate quadratic function in an efficient way (optimum use of memory storage)
b)Have a constructor that takes 4 arguments: a character indicating in which form the three other arguments should be interpreted (‘S’for Standard,‘F’for Factorised or‘V’for Vertex) and the three arguments fully defining the quadratic function in the specified form ((a, b, c), (a, R1, R2) or (a, h, k)).
c)Be able to return each individual elements of the stored quadratic function from the three possible forms (Standard: a, b, c; Factorised: a, R1, R2; Vertex: a, h, k).
d)Allow the modification of individual“standard form”elements of the quadratic function (a, b, c).
Using the template provided (main () function), briefly demonstrate the use of this class and of all the created member functions by creating and manipulating a single object of that class.
2.Add to the class functions that display on the screen the stored quadratic function. [3]
Create three member functions to display each form separately: ax²+bx+c, a(x-h)²+k and a(x-R1)(x-R2)
Create one member function to display all forms together: f(x)=ax²+bx+c=a(x-h)²+k=a(x-R1)(x-R2)
Using the template provided (main () function), demonstrate the use of these member functions.
3.Create a function GetFunctionsFromFile(filename): [3]
The function should:
a)Read all quadratic functions recorded in a text file. Each data line in the text file always consists of one of the following, to define a quadratic function:
oa letter‘S’followed by the three values defining the standard form (a, b, c)
oa letter‘F’followed by the three values defining the factorised form (a, R1, R2)
oa letter‘V’followed by the three values defining the Vertex form (a, h, k)
b)Create for each of them an object of type QuadraticF and store the created objects in a vector to obtain a list of all quadratic functions defined in the file.
Using the template (main () function) and the text file (FunctionsList.txt) provided, briefly demonstrate the use of this function by displaying on the screen all quadratic functions extracted from the text file and stored in the vector. For each quadratic function, all forms should be displayed.
4.Create two overloaded operators: [3]
Create an overloaded operator “+”, which adds one QuadraticF object to another and return the resulting new QuadraticF object. Thus, enabling the following type of operations: Funct3 = Funct1 + Funct2.
Create an overloaded operator ““, which multiplies one QuadraticF object by an integer and returns the resulting new QuadraticF object. Thus, enabling the following type of operations: Funct4 = 4 Funct3.
Using the template provided (main() function), demonstrate the use of these functions by calculating the sum of all functions extracted from the text file (FunctionsList.txt) and by multiplying the resulting QuadraticF object by 4. Display on the screen the resulting QuadraticF functions (using the three forms) resulting from both the sum and the multiplication operation.
5.Explain briefly the structure of your class (Maximum 500 Words), in terms of memory usage and“user friendliness”, how you tested it and highlight any identified issues. [1]
Notes on univariate quadratic functions.
1) Finding the Factored form, f(x) = a (x – R1)(x – R2), using the standard form f(x) = a x2 + b x + c, (if a ≠ 0):
Calculate the discriminant D=b2-4ac. Then:
-If D ≥ 0 R1 and R2 are real numbers. and
-If D < 0, R1 and R2 are complex numbers and
2) Finding the vertex form, f(x) = a (x – h)2 + k, using the standard form f(x) = a x2 + b x + c, (if a ≠ 0):
and
Submission Procedure
You should solve the problems independently from other students and submit only your own work. Submit your solution on“learning central”using the Coursework Answer Sheet provided by 18:00, Friday 26/03/2021 (week 8).
Include your answer to Question 5 in section one of the Coursework Answer Sheet. Then, directly from Microsoft Visual C++, copy and paste all your code in the relevant section of the Coursework Answer Sheet. Add a screen shot of the window showing what is printed on the screen when running your program (for example using Microsoft Snipping Tool).
All developed code should be included in the 3 files provided: QuadraticF.h, QuadraticF.cpp and Main.cpp and uploaded on“learning central”together with the Coursework Answer Sheet to facilitate our testing of your program. Any incomplete submission will be considered late.
Marking scheme
Question1 – 5 Points ; Question2 – 3 Points ; Question3 – 3 Points ; Question4 – 3 Points ; Question5 – 1 Points
Marks will be awarded for:
• A correctly functioning program. The program should operate according to the specification.
• An efficient program and elegant algorithms. Try to develop algorithms, which are efficient in terms of the amount of data, which needs to be stored (e.g. minimum number of variables used), and the speed in which they operate.
• A user-friendly program. When your program runs, the messages on the screen should be easy to understand and succinct.
• A well commented program. The judicious use of commenting is essential if somebody else is to easily understand your program.
With that in mind, each coding question will be marked using the following scheme

Programming techniques usage & understanding (70%)    Programming Style/presentation (30%)

Outstanding
(90-100%) Exceptionally comprehensive and detailed knowledge of programming concepts that goes beyond what was taught, achieving an exceptional understanding level. An exceptional effort was achieved through an unusually ingenious manner to organise and comment the code.
Excellent
(80-89%) Demonstrated a thorough and detailed knowledge, that goes beyond the taught programming concepts required to solve the problem; significant new insights. Extremely clear & well-structured program, with excellent & efficient use of comments
Comprehensive
(70-79%) A thorough usage and understanding of the taught programming concepts. A very clear and well-structured program; with a good usage of comments
Good
(60-69%) Good usage and understanding of taught programming concepts but with some minor omissions or errors. A fairly clear and well-structured program but could be structured or annotated better.
Fair
(50-59%) Adequate usage and knowledge of taught programming concepts but with some errors and omissions. Reasonably organised code but with limited effort in the presentation.
Bare pass
(40-49%) Some usage of taught programming concepts but with frequent errors and omissions. Poorly organised code, resulting in lack of clarity about it’s structure.
Fail
(30-39%) Limited usage of taught programming concepts with frequent major errors and omissions. Poor code structure suggesting a lack of understanding on how a program is organised.
Insufficient
(20-29%) Very limited usage of taught programming concepts with frequent major errors and omissions. Poor code structure demonstrating a lack of understanding on how a program is organised
Unsatisfactory
(10-19%) Minimal programming knowledge demonstrate, numerous major errors. Almost no effort was done in trying to present the code properly.
Poor
(<10%) Almost no programming work completed No effort was done in trying to present the code properly.

正文完
 0