Electricity Bill
Electricity Bill
The objective of this assessment is to check your ability to complete a project as per the provided
“Project Design”.
1. Write the source code for the classes, methods and packages EXACTLY as mentioned in the
“Project Design” section.
2. Ensure that the names of the packages, classes, methods and variables EXACTLY MATCH
with the names specified in the “Project Design” section.
3. Understand the project requirements and ACCORDINGLY WRITE the code and logic in the
classes and methods so as to meet all given requirements.
1. You are expected to create your project locally using eclipse (or any other IDE) on your desktop.
2. Once you are ready with the code, you should upload the src folder of your project in .zip
format, using the “Upload Zip File” button.
IMPORTANT NOTE 1 : The extension of the zip file should be ONLY .zip (any other zip
formats such as .7z will produce unexpected results)
IMPORTANT NOTE 2 : The .zip file should contain zip of ONLY the src folder structure from
your project. (If the zip file has anything other than the src folder structure, the result will be
unexpected. Do not zip the entire project folder structure. Just do the zip of the src folder
structure and upload it)
IMPORTANT NOTE 3 : The name of the .zip file should be <your employee number>.zip For
e.g., if your emp no. is 12345, the zip file should be named 12345.zip.
3. After uploading the zip file, you can click on “Compile & Test” button and the assessment
engine will compile your source code and test it using its pre-defined test-cases.
4. If some of the test-cases fail, you can make the fixes in your source code locally on your
desktop, and again repeat the above two steps.
5. Once you are finished with all the fixes, you can click on “Final Submission” button, which will
show you the final result/score.
NOTE that –
6. The assessment engine will create objects and invoke methods as per the project design, and
while doing so, it will use your packages, classes and methods. If your packages, classes and
methods have a name mismatch or method prototype mismatch w.r.t the expected “Project
Design”, the tool will show it as an ERROR. If your packages, classes and methods match as per
the names but do not perform the expected functionality, the tool will show it as a FAILURE.
7. Unless specified in the Project Design, DO NOT use System.exit(0) anywhere in your code.
Using System.exit(0) in your project code will cause the CPC test engine to exit and it will not
be able to run all test-cases.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Project Objective:
Create a console based Java application that would allow an electricity board clerk to compute
the electricity bill amount that needs to be paid by the customer for a given type of electricity
connection
Details:
There are two types of electric connections available. One is Domestic Connection and the other
one is Commercial Connection. The following are the formulas that are to be used for
computation of Bill for each type.
Domestic
Commercial
In Commercial Connection type, in addition to the bill amount there is an electricity duty that is
applicable. The calculations for the electricity duty is as follows:
BillAmount Electricity
Duty
Bill Amount >= 0.09
10000
Bill Amount >=5000 0.06
Bill Amount < 5000 0.02
Eg) If units consumed is 120, then amount payable is 781.32 (i.e. 766 + 15.32)
Project Design:
A. System Design:
“Incorrect Reading”
Package: com.wipro.eb.exception
Class Description
InvalidConnectionException A user defined exception
class. Details about when this
exception is given in the
respective methods
public String toString() This function should return
“Invalid ConnectionType”
Package: com.wipro.eb.entity
Package: com.wipro.eb.entity
Package : com.wipro.eb.service
The main method of the EBMain Class may look like this:
System.out.println(new ConnectionService().generateBill(130,100,"Commercial"));
TestCases:-
1. Test calculateBillAmt() with all valid values for Domestic type connection where the consumed
units are below or equal to 50
2. Test calculateBillAmt() with all valid values for Domestic type connection where the consumed
units are between 50 and 100
3. Test calculateBillAmt() with all valid values for Domestic type connection where the consumed
units are equal or above 100
4. Test calculateBillAmt() with all valid values for Commercial type connection where the
consumed units are below or equal to 50
5. Test calculateBillAmt() with all valid values for Commercial type connection where the
consumed units are between 50 and 100
6. Test calculateBillAmt() with all valid values for Commercial type connection where the
consumed units are equal or above 100
10. Test generateBill() method with all valid values and invalid values