Question: Water usage charge is calculated based on water tariff table. Table 1 shows the water tariff charges for commercial user. Table 1: Water tariff for


Water usage charge is calculated based on water tariff table. Table 1 shows the water tariff charges for commercial user. Table 1: Water tariff for Commercial user Water usage Rate (per (in meter) meter) 0-20 RM0.70 21-35 RM1.10 >35 RM1.30 Water usage charge for Commercial user is calculated based on the first water usage level. For example, if the water usage is 30 meter, it has fallen in RM1.10 per meter. However, the calculation will consider the first 20 meter, which is RM0.70 per meter and the balance of 10 meter will be calculated at RM1.10 per meter. Thus, the water usage charge for 30 meter is (20x0.70)+(10x1.10))=RM25.00. If the water usage is 50 meter, then the first 20 meter is calculated as 20x0.70=RM14.00, the second 15 meter is calculated as 15x1.10=RM16.50, and the remaining balance of 15 meter is calculated as 15x1.30=RM19.50. Thus, the aggregate water usage billed is 14+16.50+19.50=RM50.00. Write Java application with a class named as WaterTariff123456. The class consists of two user-defined methods; readData() and calcCom() [besides the default main() class). The function of the readData( method is to prompt user to enter water usage amount. The function of the calcCom() method is to calculate the water usage charge for Commercial users. Based on the above scenarios, you are required to complete the WaterTariff123456 Java class (replace 123456 with one of the metric number of your group) with the following requirements or conditions: a) You are NOT allowed to use global variable. local b) In the readData() method you should read input repeatedly until user enters a positive value (you should use looping structure here - any loop statement). c) In the calcCom () method, by using selection statement calculate the water usage charge. This method calculates charge based on the first water usage. d) In the main() method you should invoke the readData() and calcCom() methods. This process should be done repeatedly until the user wants to stop. This method will also displays the result. The result can be displayed (by using printf method) as follow: Your water usage is 50 cubic meter. Charges that you have to pay is RM50.00. e) Since you are NOT allowed to use global variables, you should use method with passing parameter and return value. Sample input/Output: (this is just a guideline) WELLCOME TO XYZ WATER Enter water usage (in cubic meter) > 50 Your water usage is 50 cubic meter. Charges that you have to pay is RM50.00. Do you want to continue (y or N) >Y Enter water usage (in cubic meter) > -40 Your have entered a negative value. Please enter again. Enter water usage (in cubic meter) > 30 Your water usage is 30 cubic meter. Charges that you have to pay is RM25.00. Do you want to continue (y or N) > N Thank You
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
