首页 新闻 聚焦 科技 财经 创业 综合 图片 视频

IT界

旗下栏目: 行业 生态 IT界 创新

ELEC129代写、代做C/C++程序语言

来源:互联网 发布时间:2021-05-20
ELEC129代写、代做C/C++程序语言
Department of Electrical Engineering and Electronics
Introduction to
Programming in C
(ELEC129)
Assignment 2
Introduction to Programming in C (ELEC129) Assignment 2
Dept. Electrical Eng. & Electronics Page 2 / 5 University of Liverpool
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 10/12/2018 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.
Introduction to Programming in C (ELEC129) Assignment 2
Dept. Electrical Eng. & Electronics Page 3 / 5 University of Liverpool
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.
Introduction to Programming in C (ELEC129) Assignment 2
Dept. Electrical Eng. & Electronics Page 4 / 5 University of Liverpool
Exercise 1 (20% of assignment mark)
Write a program that calculates the equivalent resistance of a circuit. n electrical resistors with
resistance values R1, R2, …, Rn are said to be connected in parallel if the same voltage is applied
across each. Their equivalent resistance Req is related to the values R1, R2, …, Rn by:
Req R R Rn
1
...
1 1 1
1 2
Write a program that prompts the user to enter the resistance of n resistors. The user should
be prompted continuously by using a while loop until a zero or negative value is entered (the
program should count the number of resistors n entered by the user and store the values in an
array). Use another separate loop to print the resistance values entered by the user and the
equivalent resistance Req. Test your program with R1 = 1 kΩ, R2 = 2 kΩ, R3 = 4 kΩ and R4 = 8 kΩ.
Exercise 2 (40% of assignment mark)
Write a program that calculates and prints bills for the city power company.
The program should prompt the user to enter an account number (type unsigned int) and
a use code (type char). Code R means residential use, code C means commercial use and
code I means industrial use. For valid codes, both lowercase and uppercase letters should be
accepted by the program (i.e., r or R for residential, c or C for commercial, and i or I for
industrial). The user should be prompted until a valid code is entered.
Depending on the selected Account type (use code), the user should then be prompted to
provide the consumption figures in whole numbers of kilowatts-hour (type unsigned int).
The rates vary depending on whether the use is residential, commercial or industrial, and are
computed in terms of used kilowatts-hour (kwh) as follows:
Residential (code R): £4.00 plus £0.03 per kwh used.
Commercial (code C): £40.00 for the first 1500 kwh and £0.02 for each additional kwh used.
Industrial (code I): Rate varies depending on time of usage:
- Peak hours: £53.00 for the first 1600 kwh
£0.07 for each additional kwh
- Off-peak hours: £32.00 for the first 1600 kwh
£0.04 for each additional kwh
The program should then display the account number and the amount due by the user.
The calculation of the amount due should be performed by three functions:
1. residential(): Function that takes an input argument kwh of type unsigned int
and returns the amount due as a value of type double. This function should be used to
compute the bill for residential customers.
Introduction to Programming in C (ELEC129) Assignment 2
Dept. Electrical Eng. & Electronics Page 5 / 5 University of Liverpool
2. commercial(): Function that takes an input argument kwh of type unsigned int and
returns the amount due as a value of type double. This function should be used to compute
the bill for commercial customers.
3. industrial(): Function that takes two input arguments kwh_peak and
kwh_off_peak of type unsigned int both and returns the amount due as a value of
type double. This function should be used to compute the bill for industrial customers.
In the test part of your report, specify the results provided by your program for: i) residential
use of 500 kwh, ii) commercial use of 1000 kwh; iii) commercial use of 2000 kwh; iv) industrial
use of 1000 kwh (peak hours) and 2000 kwh (off-peak hours).
Exercise 3 (40% of assignment mark)
Write a program that Computes the solutions for a quadratic equation:
0
2
ax bx c
Recall that the solutions can be real or complex numbers. The following cases may occur:
 a = b = 0: The equation is extremely degenerate and we leave it at that.
 a = 0: The equation is degenerate and has one solution x = –c/b.
 a ≠ 0: The equation has two solutions, which can be either real or complex numbers,
depending on whether the expression b
2
–4ac is positive or negative.
o b
2
–4ac > 0: The solutions are real numbers.
o b
2
–4ac < 0: The solutions are complex numbers.
o b
2
–4ac = 0: The equation has two identical (multiple) real solutions.
The solutions/roots can be calculated with the following equations:
a
b b ac
x
a
b b ac
Write a program that reads the Values for a, b and c and finds the solutions for the equation.
For each set of values (a, b, c), your program should print the equation type (extremely
degenerate, degenerate, two real solutions, two complex solutions or multiple real solutions)
along with the solution(s)/root(s) for the quadratic equation. For full marks you should use
functions where possible. Marks will also be awarded for program structure.
In the test part of your report, specify the results provided by your program for: i) a = 0, b = 0,
c = 5; ii) a = 0, b = 4, c = 3; iii) a = 1, b = 4, c = 3; iv) a = 2, b = 4, c = 3; v) a = 2, b = 4, c = 2.
NOTE: You need to include the math.h header file in your program in order to use the
sqrt() function, which calculates the Square root of a positive real number. The function
prototype is declared in math.h as follows:
double sqrt(double);
 
请加QQ:99515681 或邮箱:99515681@qq.com   WX:codehelp
  免责声明:珠穆朗玛网对于有关本网站的任何内容、信息或广告,不声明或保证其正确性或可靠性,用户自行承担使用网站信息发布内容的真假风险。
责任编辑:珠穆朗玛网