University of Leeds
Procedural Programming COMP1711 Semester 1, 2019-2020
School of Computing
Submission Deadline
Coursework 1
40 Marks
(20% of the total module marks)
Your coursework must be uploaded to Minerva before 10am on Friday 25/10/2019
Late Penalties
5% will be deducted from your overall mark for every late day
1 Skills Tested
This coursework will test your ability to write a C program that correctly uses variables, expressions, assignment, conditional execution (the if statement), and iteration (the while or for loops). It will also test your ability to write well-structured C programs with correct indentation of statements. Finally, you need to show that you are able to use comments to explain how your program works.
2 The Brief
You will write a program for an energy provider company. The program computes and prints quarterly electricity bills for different customers. It also computes and prints the quarterly profit of the company.
3 The Details
An energy provider company needs a program to compute and print electricity bills. The program takes as input the quarterly electricity consumption of a customer in kilowatt-hours (kWh) then computes and prints the bill on the screen.
The company supplies electricity to two types of customers:
1. Domestic customers.
2. Business customers.
The tariff (price/unit energy) that the company charges for electricity:
0.65/kWh for domestic customers.
1.04/kWh for business customers.
Business customers are given a 10% discount on the cost of consumed electricity if their quarterly 1
consumption is above 5000 kWh.
In addition to the cost of consumed electricity, customers must also pay a standing charge to cover transmission and operational costs. The standing charge is:
0.30/day for domestic customers.
0.96/day for business customers.
For simplicity, we will assume that a quarter has exactly 91 days.
Customers must also pay VAT (Value Added Tax) on the total amount of charges. The current VAT rates are:
5% for domestic customers.
20% for business customers.
However, if the quarterly consumption of a business customer is less than 1000kWh, they pay a reduced VAT at 5%.
Finally, business customers must also pay a Climate Change Levy (CLL) at 0.00847/kWh.
3.1 Examples
Here are some examples of how to compute bills for both types of customers.
Example 1. A domestic customer consumed 300kWh in one quarter:
195.00 27.30 222.30 11.115 233.42
Example 2. A domestic customer consumed 0kWh in one quarter:
0.00 27.30 27.30 1.365 28.66
Example 3. A business customer consumed 1631 kWh in one quarter:
This customer is not entitled to the 10% discount since their consumption is not above 5000 kWh, and they have to pay VAT at 20% since the consumption is not less than 1000 kWh:
1696.24 87.36 1783.60 356.72 13.81457 2154.13
Example 4. A business customer consumed 999 kWh in one quarter:
This customer is not entitled to the 10% discount since their consumption is not above 5000 kWh, but they pay VAT at 5% since the consumption is less than 1000 kWh:
1038.96 87.36 1126.32 56.316 8.46153 1191.10
Electricity cost
Standing charge (91 days)
Total charges
VAT at 5% (on 222.30)
Amount due (rounded to nearest penny)
Electricity cost
Standing charge (91 days)
Total charges
VAT at 5% (on 27.30)
Amount due (rounded to nearest penny)
Electricity cost
Standing charge (91 days)
Total charges
VAT at 20% (on 1783.60)
CLL
Total amount due (rounded to nearest penny)
Electricity cost
Standing charge (91 days)
Total charges
VAT at 5% (on 1126.32)
CLL
Total amount due (rounded to nearest penny)
300 * 0.65 =
91 * 0.30 = 195.00 + 27.3 = 222.30 * 0.05 =
0 * 0.65 =
91 * 0.30 = 0.00 + 27.3 = 27.3 * 0.05 =
1631 * 1.04 =
91 * 0.96 = 1696.24 + 87.36 = 1783.60 * 0.20 = 1631 * 0.00847 =
999 * 1.04 =
91 * 0.96 = 1038.96+ 87.36= 1126.32* 0.05 = 999 * 0.00847 =
2
Example 5. A business customer consumed 6431 kWh in one quarter:
This customer is entitled to a 10% discount on electricity cost since their consumption is above
5000 kWh, but they pay VAT at 20% since the consumption is not
below 1000 kWh:
6688.24 668.824 6019.416 87.36 6106.776 1221.3552 54.47057 7382.60
Electricity cost
Discount (10%)
Electricity cost after discount
Standing charge (91 days)
Total charges
VAT at 20% (on 6106.776)
CLL
Amount due (rounded to nearest penny)
3.2 Computing the Quarterly Profit
For computing the quarterly profit, we use the following equation:
P= R C Equation 1
Where:
6431 * 1.04 = 6688.24 * 0.10 = 6688.24 668.824 = 0.96 * 91 = 6019.416+ 87.36= 6106.776 * 0.20 = 6431 * 0.00847 =
P is the quarterly profit (GBP).
R is the quarterly revenue, i.e. the total amount of money collected from all customers (GBP)
in a quarter.
C is the total quarterly costs of the company (GBP).
The revenue should not include money collected for VAT and CLL because these taxes are forwarded to the government.
For simplicity, we will assume that the quarterly cost is computed using the following equation:
C = E * Ck Equation 2
Where:
3.3
E is the total amount of electricity sold to all customers in a quarter (kWh).
Ck is the average cost of providing 1 kWh of electricity to customers. This figure includes all kinds of costs incurred by the company such as transmission, distribution, and other operational costs. The current value of this figure is 0.48/kWh.
The Task
Write a C program that can be used by the above company to:
1. Compute and print the bill for a domestic customer.
2. Compute and print the bill for a business customer.
3. Show the quarterly profit of the company.
The program should be menu driven. When the program is run a menu identical to the following one should appear on the screen:
The program then waits for the user to enter the number of an option. 3
Option 1
If the user enters 1, the program prompts the user to enter the quarterly consumption of a domestic customer then computes and displays the details of the bill on the screen. The bill should be similar to the following one and should include all the details shown:
Option 2
If the user enters 2, the program prompts the user to enter the quarterly consumption of a business customer then computes and displays the details of the bill on the screen. If the customer is not entitled to the 10% discount, the bill should be similar to the following one and include all the details shown:
If the user is entitled to the 10% discount, then the bill should look like the following and include all the details shown:
Please note that you are only required to round the final amount (the amount to pay) to the nearest penny. You do not need to round other values such as the cost of consumed electricity, VAT, or CLL. Obviously, this is not realistic because values that represent money should always be rounded to two decimal places. However, rounding the intermediate values is more problematic than it appears (can you explain why?). We will accept for this coursework not to round intermediate values.
Option 3
If the user selects option number 3, the program displays the quarterly profit report of the company. The report should look like the following and include all the details shown:
4
In all the above cases, once a bill or a report is printed, the main menu is displayed again and the program prompts the user to enter the number of an option.
Option 4
Finally, if the user enters 4, the program terminates. Note that this program does not retain any data after it is terminated. We will accept this shortcoming for this coursework.
4
General Implementation Guidelines
1. In this program you should only use the following types of C language statements:
Variable declarations.
The printf and scanf functions.
Expressions and the assignment statement.
The if else statement.
Iteration statements (a while or for loop).
2. Please do NOT use arrays, structs, functions, or pointers even if you are already familiar with them.
3. Write the program in standard C. If you write your code in any other language, it will NOT be marked, and you will score zero.
4. This is an individual project, and you are not supposed to work in groups or pairs with other students.
5. Be aware that plagiarising your code will earn you a zero mark and will have very serious consequences. It is much better to submit your own partially finished work, than to fall into the trap of plagiarism. We use a software to detect plagiarism automatically, so if you do work with someone else, or submit someone elses work it WILL be detected.
6. At the top of you program file please include the following information within a comment, and fill in your name, student id, email, and the date on which you commenced writing your program:
/************************************************************************* University of Leeds
School of Computing
COMP1711- Procedural Programming
Coursework 1
I confirm that the following program has been developed and written by me and it is entirely the result of my own work. I also confirm that I have not copied any parts of this program from another person or any other source or facilitated someone to copy this program.
I confirm that I will not post this program online or share it with anyone before the end of the semester.
5
5
Submission Instructions
1. Before submitting your coursework, you must make sure that you can compile your program on our schools Linux machines (e.g. DEC-10 Lab machines). You must also thoroughly test your program on these machines. Submissions that do not compile and run on our Linux machines will score zero even if they work perfectly well on another platform. Hence, if you have developed your program on a Windows or Mac PC or laptop, you must not submit your project until you have made sure that it does compile and run on our Linux computers without any problems.
2. You should upload to Minerva a single plain text file containing the entire code of your program. The file name should have the .c extension. Please make sure that you have uploaded the correct file by downloading it from Minerva and checking that it is indeed what you intended to submit. If you submit a non-plain text or a corrupt file, your coursework may be rejected, and you will score 0.
6
3. Do not upload executable or binary files.
Marking Scheme
7. i.
ii. iii.
iv. v.
Student Name:
Student ID:
Email:
Date Work Commenced:
*************************************************************************/
To simplify program development, you will develop your program in iterations:
In the first iteration you will write the code that displays the menu, prompts the user to enter the number of an option and read and process the input value. In this iteration, the program will simply display the message This option is not yet implemented when the user chooses options 1, 2, or 3.
Once you are satisfied that the menu is working properly, you will add the code for computing and displaying the bill of a domestic customer (option 1). You will then test this option using Examples 1 and 2 above.
In the third iteration, you will implement the code for computing and displaying the bill of a business customer (option 2). You will then test this option using Examples 3, 4, and 5 above.
In the fourth iteration, you will add the code that updates the revenue and total amount of sold energy every time a bill is created.
Finally, you will implement option 3 that computes the quarterly cost (using Equation 2) and the quarterly profit (using Equation 1) and displays the profit report. Then you will test this option by making sure that the revenue, cost, and profit are correct when the above 5 examples are used as input.
If you do not include the above statement in your submitted file, your coursework may be rejected, and you will score 0 in this coursework.
The program displays the menu and process user options correctly The program computes and prints domestic bills correctly
The program computes and prints business bills correctly
The program computes the profit and prints the profit report correctly The program has a good structure and is clear and efficient
[6 marks] [8 marks] [12 marks] [6 marks] [4 marks]
6
The program code is indented properly [2 marks] The program uses comments properly [2 marks]
Total
Enjoy
Dr M. A. Alsalka
[40 marks]
7
Reviews
There are no reviews yet.