ELEC129 Introduction to Programming in C Assignment 1
Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit
Introduction to Programming in C
(ELEC129)
Assignment 1
Objectives
To design, implement and document simple modular programs that use functions and flow control statements.
Assessment
This assignment is an assessed component and the mark for this work will contribute towards the overall module mark. The weight of Assignment 1 is 15%. The marking criteria can be found in CANVAS.
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 or PDF file in the Assignments section of ELEC129 in CANVAS by Wednesday 26/10/2022 23:59 GMT (week 5). Email submissions will not be accepted. Delay penalties apply.
Important: grading of all coursework is anonymous, do not include your name, student ID number, email or any other personal information in the submitted report. Submissions must be a single Word or PDF file containing the work done by the student (do not submit your source code or executable files). 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 not sure what a global variable is, ask the module coordinator.
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.
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 marks 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 marks for this.
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 (https://www.liverpool.ac.uk/aqsd/academic-codes-of-practice/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 in 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.
Exercise 1 (40% of assignment mark)
Write a program that prompts the user to provide two characters, reads the two characters from the keyboard and prints on the screen the shape of a diamond using those characters.
For example, if the characters are '#' and '*', then the program should display the following: *
*#*
*###*
*#####*
*###*
*#*
*
Make your program modular by organising the code into two functions as detailed below.
Write a function info that displays instructions to the user, reads two characters from the keyboard and returns those values to the calling function (i.e., the main function).
Write a function diamond that takes two parameters of type char and prints on the screen the shape of a diamond using the two characters provided as the actual arguments.
The main function should call first the info function to instruct the user to input two characters and read those characters from the keyboard. The main function should pass these values as arguments to the function diamond to print the diamond shape on the screen.
Exercise 2 (60% of assignment mark)
Write a program that performs the following input/output operations:
Part I – Personal details:
Asks the user to provide the following information:
o Full name (including title, forename, middle name and surname, as applicable)
o Date of birth
o Address line
o City
o County
o Postcode
o Telephone number
o Email address
Part II – Employment details
Asks the user to provide the following information:
o Position/job title
o Employer
o Hourly pay rate (in GBP/hour), including pounds and pence (e.g., 14.79)
o Number of hours worked per week
o Income tax rate (as a single percentage value within the interval 0.0-100.0)
Part III – Summary
Shows a list including all the items above (both Part I and Part II) along with the input
information provided by the user.
Shows the gross pay, taxes and net pay for the following intervals: weekly, monthly
and annually.
Make your program modular (e.g., using a function to implement each part of the program). You can decide how to organise the program into the functions that you consider appropriate.
In the test part of your report, show the output of your program for a user with the following salary details: i) work hours equal to 24 hours/week at 8.50 GBP/hour, with 20% income tax; ii) 30 hours/week at 30 GBP/hour, with 25% income tax; iii) 55 hours at 9.90 GBP/hour, with 30% income tax; and iv) 40 hours at 15 GB/hour, with 40% income tax.
2022-10-26