Introduction to Programming in C (ELEC129) Assignment 2

C代写:这是一个C作业代写,涉及C语言

Introduction to Programming in C (ELEC129) Assignment 2
Objectives
To design, implement and document simple modular programs that use functions and loops.
Assessment
This assignment is an assessed component and the mark for this work will contribute towards the overall module mark. The weight of Assignment 2 is 22%. The marking criteria can be found in the Exam Resources section of ELEC129 in VITAL.
This assignment is composed of a number of exercises. The relative weight of each exercise on the overall assignment mark is indicated between brackets.
Instructions
Students are required to do all exercises and submit a single Word file in the Assessment section of ELEC129 in VITAL (https://vital.liv.ac.uk) by Tuesday 12/12/2017 at 17:00 (5pm) UK local time (week 12 of semester 1). Delay penalties apply. Please double check your report and make sure your work is in its final form before submission as the online application will not allow resubmissions. Email submissions and/or resubmissions will not be accepted.
Submissions must be a single Word file containing the work done by the student (student name and student ID should be clearly stated in the first page). The file must contain two parts for each exercise proposed in this assignment as detailed below.
Part I: The first part must contain the source code. Please use font Courier New with a size of 8 points, use indentation to make the code readable, and observe the following requirements:
 The source code must be the result of your own original and individual work.
 The source code must be entirely written in the C programming language. Source code
written in any other programming languages (e.g., C++) will receive a mark of zero.
 The use of global variables is (in general) not needed in ELEC129 assignments and its use is not allowed unless otherwise stated. All variables should be local to a function (i.e., declared within the body of a function). The use of global variables will be
penalised. If you are in doubt, ask a lab demonstrator to check your source code.
 All exercises can be solved based on concepts explained in previous lectures. Students are allowed to use concepts from other (future) chapters but this is not expected. Feel
free to discuss your approach to solving the exercises with a lab demonstrator.
Part II: The second part must contain a detailed explanation of the software development process followed by the student (i.e., the first five steps of the software development method):
1. Problem specification: Formulation of the problem and its objectives.
2. Analysis: Identification of: i) inputs, ii) outputs, and iii) other relevant aspects,
requirements or constraints (e.g., relevant formulas, etc.).
3. Design: Formulation of the algorithm (list of steps) needed to solve the problem. At
this stage, the problem should be divided into a number of sub-problems that can be solved using functions.
Dept. Electrical Eng. & Electronics Page 2 / 5 University of Liverpool

Introduction to Programming in C (ELEC129) Assignment 2
4. Implementation: List of functions used in the program (function names), indicating for each function which step(s) of the algorithm is/are implemented by the function.
5. Testing and verification: Explanation of how the program was tested and verified. Snapshots of the program’s output window can be obtained by using [Alt] + [PrtScr(or PrintScreen)] and pasting into the report.
Please indicate clearly if in your opinion the program works correctly. If you do not think the program works correctly or does not compile, indicate what the problems are. You will then be able to get points for that programming task. If in the testing section of your design document you have indicated that the program works correctly but it turns out that your code does not even compile (because of syntax errors, for example) you will not receive adequate points.
Academic integrity
Students should familiarise themselves with Section 6 of the University’s Code of Practice on Assessment, which provides important information regarding the submission of assessed coursework (link: http://www.liv.ac.uk/tqsd/code-of-practice-on-assessment).
Students should also familiarise themselves with Section 9 (Academic Integrity) and Appendix L (Academic Integrity Policy) of the University’s Code of Practice on Assessment which provide the definitions of academic malpractice and the policies and procedures that apply to the investigation of alleged incidents (including collusion, plagiarism, fabrication of data, etc.).
Students found to have committed academic malpractice are liable to receive a mark of zero for the assessment or the module concerned. Unfair and dishonest academic practice will attract more severe penalties, including possible suspension or termination of studies.
By electronically submitting this coursework you confirm that:
 You have read and understood the University’s Academic Integrity Policy.
 You have acted honestly, ethically and professionally in conduct leading to assessment
for the programme of study.
 You have not copied material from another source nor committed plagiarism nor
fabricated data when completing the attached piece of work.
 You have not previously presented the work or part thereof for assessment for
another University of Liverpool module.
 You have not copied material from another source, nor colluded with any other
student in the preparation and production of this work.
 You have not incorporated into this assignment material that has been submitted by
you or any other person in support of a successful application for a degree of this or any other University or degree awarding body.
Students are encouraged to contact the module instructor if any clarifications are needed.
Dept. Electrical Eng. & Electronics Page 3 / 5 University of Liverpool

Introduction to Programming in C (ELEC129) Assignment 2
Exercise 1 (50% of assignment mark)
Write a program that calculates the monthly bills for a telecommunications services company.
The company provides three services (telephone, internet and television) and each user can have only one service. The program should prompt the user to enter an account number (type unsigned int) and a service code (type char). Code P means telephone service, code I means internet service and code T means television service. The program should prompt the user until a valid code is entered (both lowercase and uppercase letters should be accepted).
The user should be prompted to provide the service consumption figures in number of minutes (type unsigned int). The rates depend on the service as follows:
Telephone (code P): Internet (code I):
Television (code T):
£15.00 line rental plus £0.05 per minute used.
£20.00 for the first 1000 minutes of internet connection (flat rate) and £0.02 for each additional minute the user was connected to internet.
TV users can either have a basic or a premium pack (but not both). For TV users, the program should also prompt the user to indicate the pack type. The rate varies depending on the user’s TV pack as follows:
– Basic pack: £5.00 for the first 60 minutes (flat rate) £0.01 for each additional minute
– Premium pack: £10.00 for the first 60 minutes (flat rate) £0.02 for each additional minute
The program should display the account number and the amount due by the user.
The calculation of the amount due should be performed by three functions:
1. telephone(): Function that takes an input argument mins of type unsigned int and returns the amount due as a value of type double. This function should be used to compute the amount to be charged to telephone users.
2. internet(): Function that takes an input argument mins of type unsigned int and returns the amount due as a value of type double. This function should be used to compute the amount to be charged to internet users.
3. television(): Function that takes two input arguments pack_type and mins, both of type unsigned int, and returns the amount due as a value of type double. This function should be used to compute the amount to be charged to television users.
In the test part of your report, specify the results provided by your program for: i) 100 minutes of phone service; ii) 500 minutes of internet service; iii) 2000 minutes of internet service; iv) 1000 minutes of basic TV service; and v) 1000 minutes of premium TV service.
Note: You may want to use the toupper function in your program, which is defined in the ctype.h header file. Check your lecture notes or a C reference for details on how to use it.
Dept. Electrical Eng. & Electronics Page 4 / 5 University of Liverpool

Introduction to Programming in C (ELEC129) Assignment 2
Exercise 2 (50% of assignment mark)
In probability theory and statistics, sometimes it can be useful to compute the value of a metric called kurtosis. This metric is used to describe certain properties of a random variable (i.e., a variable that can take random values). Let 𝑥1, 𝑥2, … , 𝑥𝑛 denote a sequence (vector) of n samples (values) taken from a random variable of interest. Assume in this exercise that all n samples can only take positive real values (including zero). The sample kurtosis of a sequence of n values (𝑥1, 𝑥2, … , 𝑥𝑛) can be computed based on the following expression:
𝑛1 ∑𝑛𝑖=1(𝑥𝑖 −𝑥)4 𝑛1 [(𝑥1 −𝑥)4 + (𝑥2 −𝑥)4 + … + (𝑥𝑛 −𝑥)4] 𝑘𝑢𝑟𝑡𝑜𝑠𝑖𝑠 = (𝑛1 ∑𝑛𝑖=1(𝑥𝑖 − 𝑥)2)2 = (𝑛1[(𝑥1 − 𝑥)2 + (𝑥2 − 𝑥)2 + … + (𝑥𝑛 − 𝑥)2])2
where 𝑥 represents the mean/average value of the sequence, which is given by: 1𝑛1
𝑥 = 𝑛 ∑ 𝑥𝑖 = 𝑛 (𝑥1 + 𝑥2 + … + 𝑥𝑛 ) 𝑖=1
Write a program that computes the sample kurtosis of a sequence of positive real values (including zero) entered by the user. The program should have a maximum capacity of 10 values. The user should be prompted continuously until either of these events occurs:
a) The user enters a negative value (this means that the user has no more values).
b) The maximum capacity is reached (i.e., the user has entered 10 values). When the 10th value is entered, the program should display a message indicating that the maximum
capacity has been reached and more values cannot be accepted.
The program will then compute the sample kurtosis based on the valid values entered by the user (positive and zero) and display them (one per line) as well as the kurtosis, as shown in the following example (note that all indexes are displayed with 2 digits, e.g., Value 01):
Value 01 = 26.34
Value 02 = 4.34
Value 03 = 1.245
——————–
Kurtosis = 1.5
In the test part of your report, indicate the results provided by your program for these cases:
 CaseI: 𝑥1 =10, 𝑥2 =15, 𝑥3 =20, 𝑥4 =25, 𝑥5 =30, 𝑥6 =35
 CaseII: 𝑥𝑖 =𝑖 for 𝑖=1,2,…,15 Notes:
– You should use an array to store the values entered by the user.
– You should use separate loops to capture the values entered by the user, compute the
kurtosis, compute the mean, compute powers, and display the entered values.
– Your program should be modular and use functions. You should use separate functions
to compute the kurtosis, compute the mean, compute powers as well as other tasks.
– The use of mathematical functions provided by C (e.g., pow) or any external C library is not allowed. You should implement your own functions to compute kurtosis, mean,
powers or any other intermediate calculations required by your program.
Dept. Electrical Eng. & Electronics Page 5 / 5 University of Liverpool

发表评论

电子邮件地址不会被公开。 必填项已用*标注