代写 CPT106 Assessment 1

CPT106 Assessment 1
CPT106 C++ Programming and Software Engineering II
Assessment 1
Contribution to Overall Marks 70%
Release Date May 5, 2022, 23:59
Submission Deadline May 25, 2022, 23:59
How should the work be submitted?
SOFT COPY ONLY!
(This is an INDIVIDUAL WORK and MUST be submitted through Learning Mall so that
we can run your programs during marking.)
1. Create a Solution and set your student ID as the solution name.
2. Create a project for each problem within the solution. The project name should be
Problem1, Problem2 and so on for the problems below.
3. All C++ source code files (including solution and project files) for all tasks should be
zipped into a single file named with your student ID number and submitted to
Learning Mall.
4. Late Submission Policy: 5% of the total marks available for the assessment shall be
deducted from the assessment mark for each working day after the submission date,
up to a maximum of five working days.
Assessment Overview
This assessment aims at testing basic concepts of C++ programming, such as inheritance, information
hiding, overloading, friend functions, vector, constructor and related software engineering concepts. The
marking criteria are as follows:
CPT106 Assessment 1
2
Write a function
Int[] union_Array (int a[], int lenA, int b[], int lenB)
that constructs the union of two integer arrays and removes any element that occurs more than once.
For example, if two arrays of the union_Array are {1, 8, 16 } and {11, 8, 7, 1}, it will return an array
of {1, 8, 16, 11, 7}.
Tasks:
1. The length of two arrays should be different and defined by constants using “#define”. (1
mark)
2. Arrays are inputted from the keyboard.(1 mark)
3. Call the function union_Array in your main function. Initialize two arrays. Print out the new
array (there is no requirement for the order of the output elements). (1 marks)
4. Compile and run correctly(2 marks)
Given a student class to represent student information as follows:
class Student{
string stuId;
string name;
double mathScore;
double chineseScore;
double englishScore;
};
Write a program to achieve the following tasks:
1. Use an array to save student information. The length of the array should be defined by a
constant using “const”. (1 mark)
2. Student information is inputted from the keyboard. (1 mark)
3. Print out the student ID and average mark of three courses for each student in a descending
sequence.(1 mark)
4. Print out student ID whose average mark is smaller than the average mark of all students.(1
mark)
5. Compile and run correctly. (2 marks)
Given a student structure to represent student information as follows:
structure student{
string stuId;
string name;
double mathScore;
double chineseScore;
double englishScore;
};
Problem 1 (5 marks)
Problem 2 (5 marks)
Problem 3 (5 marks)
CPT106 Assessment 1
3
Write a program to achieve the following tasks:
1. Use a pointer and linked list to save student information. The length of the linked list (number
of student objects) should be inputted from the keyboard. (1 mark)
2. Student information is inputted from the keyboard. (1 mark)
3. Print out the student ID and average mark of three courses for each student in a descending
sequence. (1 mark)
4. Print out student ID whose average mark is smaller than the average mark of all students. (1
mark)
5. Compile and run correctly. (1 mark)
Given a function header as char *findC (char const *source, char const *obj):
Write a program to achieve the following tasks:
1. Write a function to search a character sequence pointed to by a pointer (called “obj”), in
another character sequence (called “source”). Return the pointer pointing to the found
character. If there is more than one target found in the source, return the pointer pointing to
the first one. (2 marks)
Eg1: search for “C” in “ABCDEF”, return the pointer point to ‘C’.
Eg2: search for “Z” in “ABCDEF”, return a NULL pointer.
Eg3: search for “CD” in “ABCDEF”, return the pointer point to ‘C’.
Eg4: search for “CF” in “ABCDEF”, return a NULL pointer.
Eg5: search for “A” in “ABCAFC”, return the pointer point to the first ‘A’.
2. Write a main function to input two strings by the keyboard and print the position of the
pointer in the source string(print -1 if the function returns a NULL pointer). (1 mark)
3. Compile and run correctly. (2 marks)
Given a circle class to represent circle information as follows:
class Circle{
int x;
int y;
double radius;
};
Write a program to achieve the following tasks:
1. The centre point of (x,y) and radius should be inputted from the keyboard. (1 mark)
2. Define a method that can calculate and return the circle’s area. (1 marks)
3. Define an overloading operator + to add two circle objects and get a new circle object. The
centre point of the new circle object is the same as the centre point of the first circle object.
The area of the new circle object should be the sum of the areas of two circle objects (You
can calculate the radius of the new circle based on the sum of the area of two circles). (2
marks)
Problem 4 (5 marks)
Problem 5 (10 marks)
CPT106 Assessment 1
4
4. Define a function to print relations of two circles(interaction, tangency, separation and
inside) (2 marks)
5. Define a main function to input two circle objects, get a new circle object based on these two
circle objects and print the relations of these two circle objects. (2 marks)
6. Compile and run correctly. (2 marks)
Given a set of x,y data points, it is often necessary to automatically calculate an equation which
gives the best fit line through the data. This type of analysis is known as line fitting or regression
analysis.
The mathematical basis behind line fitting is shown below. You have a set of data points represented
by (x1,y1), (x2,y2) ..... (xn, yn). You want an equation which represents this data, the exact type of
equation will depend on the way in which the data varies. Given any mathematical relationship
between x and y it should be possible to generate a line fitting algorithm. The line fitting algorithm is
described below.
Straight line
The equation for a straight line is: y = ax + b. Suppose that we have n points of (x,y) values from the
text file, the values of a and b for the best fit line that is the best approximation of the given set of
data points can be obtained from the following equation:
is the difference between the two dot products
(a1b2 - a2b1). Create a C++ program to calculate its value.
Distance
The distance from a point P(x,y) to the line ax+by+c=0 is the length of the perpendicular line from
the point P to the line:
Problem 6 (30 marks)
CPT106 Assessment 1
5
Distance =
|ax+by+c|
√𝑎2+𝑏
2
where (x,y) is the coordinate value for point P.
Standard error of distance for all the points: SE=√
∑ (𝑥𝑖−𝑥̅)
𝑛 2
𝑖=1
𝑛−1
Where 𝑥̅is the mean distance of all points, 𝑥𝑖
is the distance of Point Pi , n is the number of all
points.
Please complete the assessment according to the following steps: (30 marks)
1. Create a file operation class “FileOp” with functions as follows: (12 marks, 3 marks per question)
a) It can allow users to input points from the keyboard and save these points into a text file.
b) It can read points from the text file.
c) It can delete a point from the text file.
d) It can check if a point is in the text file.
2. Create a class “LineFitting” with functions as follows: (10 marks, 2 marks per question)
a) It can calculate the parameters of a, b and c for the best fit line ax+by+c=0.
b) It can calculate the distance between each point in your file and the best fit line.
c) It can find the best point from the file, which is not in the best fit line but has a minimal
distance compared to other points.
d) It can find the worst point from the file, which has the maximal distance compared to other
points.
e) It can calculate the standard error of distance for all the points.
3. Create a main method in your program to achieve the following functions: (8 marks)
a) Create a main method. (2 mark)
b) Create a text file using the “FileOp” class with some points. (1 mark)
c) Print out the equation of the best fit line (e.g. 3x+2y+3=0). (1 mark)
d) Ask the user to input a point and print out whether the point is in the text file or not. If it is
in the file, then print out its position. (1 mark)
e) Print out the worst point that has a maximal distance to the best fit line in all the points. (1
mark)
f) Print out the standard error for all the points. (1 mark)
g) Ask the user to input a point and delete it from the file if the point exists in the text file. (1
mark)
Online trading systems can help customers buy goods from the internet. In this question, you are
required to write a program to simulate the trading procedure and allow customers to query and buy
some goods.
Tasks:
(1) Create a Product class with several private member variables, such as product id, product name,
product amount and price. (2 marks)
(2) Create a base class Person with several private member variables, such as person name, gender,
mobile number and address. The gender should be an enum. (2 marks)
(3) Create a subclass Customer based on the Person class. It has extra private member variables, such
as customer id, capital and a vector of products the customer is purchasing. Each customer has
10,000 RMB initial capital. (2 marks)
(4) Create a subclass Manager based on Person class. The manager has extra private member variables,
such as age and title. (2 marks)
(5) Create a MainProcess class. It has private member variables, such as a vector of products to save all
product information, a vector of customers to save all customers, a manager who can manage
customers and products, a customer who is purchasing products. In addition, it also has some
functions to output operation menus both for managers and customers to choose from. (2 marks)
Problem 7 (40 marks)
CPT106 Assessment 1
6
(6) When the program runs, it shows a menu as follows: (2 marks)
Fig.1. Main operation menu
There are two roles in this online trading system (manager and customer). Different roles have
different functions.
(7) If the input is 1, then move to manager’s menu as follows: (2 marks)
Fig.2. Manager’s operation menu
The manager can add new products, query products, add new customers and query customers. If the
user inputs 5, then the program will move to the parent menu shown in Figure 1 (main operation
menu).
a) Add products: manager can add new products into a product vector so that customers can
buy these products. (2 marks)
Fig.3. Operation of adding products
The manager can continue to input product id, name, amount and price to create and add
new products into the product vector. Duplicated product id cannot be added to the product
vector. When the manager input 0 to stop adding, the manager operation menu will output on
the window, and the manager can input another number to do other operations.
CPT106 Assessment 1
7
b) Query products: manager can input a product id to query a particular product or input “*” to
list all products in the product vector. Output “No product found!” if there is no particular
product. (2 marks)
Fig.4. Operation of querying products
c) Add customers: manager can add new customers to the customer vector. (2 marks)
Fig.5. Operation of adding customers
The manager can input customer id, name, gender, mobile number and address to create and
add new customers into the customer vector. Duplicated customer id cannot be added to the
customer vector. When the manager inputs 0 to stop adding, the manager operation menu
will be outputted on the window, and the manager can input another number to do other
operations.
d) Query customers: manager can input a customer id to query a particular customer or input
“*” to output all customers in the customer vector. “No customer found!” will be outputted if
there is no particular customer. (2 marks)
Fig.6. Operation of querying customers
e) Move to parent menu: if the manager inputs 5, then the program moves to the main operation
menu shown in Figure 1. (2 marks)
(8) On the main operation menu, if the user inputs 2, then the system will ask the user to input a
customer id to confirm which customer will purchase products. If the customer id exists in the
customer vector, then the operation menu for customers will be outputted as Figure 7 shows. (2
CPT106 Assessment 1
8
marks)
Fig.7. Customer’s operation menu
otherwise, ask users to input a new customer id or a special string “quit” to move to the parent
operation menu shown in Figure 8 (it means that you should create at least one customer before you
can enter into the customer operation menu and start to purchase products).
Fig.8. Failed to find the customer Id
a) Add products into cart: a customer can add products into the cart so that the customer can
buy these products. Customer can input product id and the amount he/she wants to buy. The
program will show a reminder if the customer does not have enough capital or the amount
the customer wants is larger than the available amount of the product. The program should
output successful information if the adding operation runs successfully. In addition, the
amount of product in the product vector should be deducted accordingly. (2 marks)
Fig.8. Operation of adding products into cart
b) Query products in cart: customers can query all products added in the cart. The customer can
input a specific product id to query one product or input “*” to list all products in the cart. (2
marks)
CPT106 Assessment 1
9
Fig.9. Operation of querying products in cart
c) Check up: customer can check up the bill for all products in the cart. It will list customer’s
id, name, gender and capital, all products in the cart and the total price. (2 marks)
Fig.10. checking up operation
If the cart is checked up successfully, the capital of the customer should be deducted based
on the total price of products the customer has bought.
(9) Make sure your source code has some comments (3 marks) to help us understand and can be
compiled successfully (5 marks).

热门主题

课程名

mktg2509 csci 2600 38170 lng302 csse3010 phas3226 77938 arch1162 engn4536/engn6536 acx5903 comp151101 phl245 cse12 comp9312 stat3016/6016 phas0038 comp2140 6qqmb312 xjco3011 rest0005 ematm0051 5qqmn219 lubs5062m eee8155 cege0100 eap033 artd1109 mat246 etc3430 ecmm462 mis102 inft6800 ddes9903 comp6521 comp9517 comp3331/9331 comp4337 comp6008 comp9414 bu.231.790.81 man00150m csb352h math1041 eengm4100 isys1002 08 6057cem mktg3504 mthm036 mtrx1701 mth3241 eeee3086 cmp-7038b cmp-7000a ints4010 econ2151 infs5710 fins5516 fin3309 fins5510 gsoe9340 math2007 math2036 soee5010 mark3088 infs3605 elec9714 comp2271 ma214 comp2211 infs3604 600426 sit254 acct3091 bbt405 msin0116 com107/com113 mark5826 sit120 comp9021 eco2101 eeen40700 cs253 ece3114 ecmm447 chns3000 math377 itd102 comp9444 comp(2041|9044) econ0060 econ7230 mgt001371 ecs-323 cs6250 mgdi60012 mdia2012 comm221001 comm5000 ma1008 engl642 econ241 com333 math367 mis201 nbs-7041x meek16104 econ2003 comm1190 mbas902 comp-1027 dpst1091 comp7315 eppd1033 m06 ee3025 msci231 bb113/bbs1063 fc709 comp3425 comp9417 econ42915 cb9101 math1102e chme0017 fc307 mkt60104 5522usst litr1-uc6201.200 ee1102 cosc2803 math39512 omp9727 int2067/int5051 bsb151 mgt253 fc021 babs2202 mis2002s phya21 18-213 cege0012 mdia1002 math38032 mech5125 07 cisc102 mgx3110 cs240 11175 fin3020s eco3420 ictten622 comp9727 cpt111 de114102d mgm320h5s bafi1019 math21112 efim20036 mn-3503 fins5568 110.807 bcpm000028 info6030 bma0092 bcpm0054 math20212 ce335 cs365 cenv6141 ftec5580 math2010 ec3450 comm1170 ecmt1010 csci-ua.0480-003 econ12-200 ib3960 ectb60h3f cs247—assignment tk3163 ics3u ib3j80 comp20008 comp9334 eppd1063 acct2343 cct109 isys1055/3412 math350-real math2014 eec180 stat141b econ2101 msinm014/msing014/msing014b fit2004 comp643 bu1002 cm2030
联系我们
EMail: 99515681@qq.com
QQ: 99515681
留学生作业帮-留学生的知心伴侣!
工作时间:08:00-21:00
python代写
微信客服:codinghelp
站长地图