computer programming Write a C program that will calculate and print monthly water bills. The total...
Write a C program that will calculate and print monthly water bills. The total units consumed per month are derived from subtracting the previous meter readings with the current meter reading. The charges are calculated based on the rates stated in Table 2. The sample output is shown in Figure 16 Tulis aturcara Cyang akan mengira dan mencetak bil air bulanan Jumlah unit yang diguna sebulan dikira dengan menolak bacaan meter sebelum dengan bacaan meter terkinl. Caj dikira berdasarkan kadar yang dinyatakan di Jadual 2.Sampel keluaran ditunjukkan di Rajah 16 Table 2 Jadual 2 First Rate RM 0.10 for first 500 units RM 0.25 for first 1000 units RM 0.50 for first 1500 units User Code User Type Household Office Industry Second Rate RM 0.25 for the following units RM 0.50 for the following units RM 0.75 for the following units 1 2 3 The program should include the following functions: [Aturcara perlu mengandungi fungsi-fungsi berikut:] (a) int calculateUsage (int previous_reading, int current_reading) that accepts value of previous reading and current reading of water consumption and return their difference Ant calculateUsage (int previous_reading, int current_reading) yang menerima nilai bacaan sebelum dan terkini penggunaan air dan memulangkan nilai perbezaan mereka) (b)void calculateCharge (int user_code, int usage, float charges) accepts user code, water usage and, calculate and return by reference the charges. Charges rate depends on the user code. [void calculateCharge (int user_code, int usage, float *charges) yang menerima kod pengguna, penggunaan air dan, mengira dan memulangkan alamat caj. Kadar caj beergantung kepada kod pengguna (c)void printBill (float charges) accepts and prints charges [void printBill(float charges) menerima dan mencetak caj. Sample output: Please enter Previous reading: 325682 Current reading: 384511 Please enter user code: 1 HOUSEHOLD consumption is 58829 units. Total charge for this month is: RM 14632.25 Figure 16 Rajah 16] (20 Marks/Markah)
Write a C program that will calculate and print monthly water bills. The total units consumed per month are derived from subtracting the previous meter readings with the current meter reading. The charges are calculated based on the rates stated in Table 2. The sample output is shown in Figure 16 Tulis aturcara Cyang akan mengira dan mencetak bil air bulanan Jumlah unit yang diguna sebulan dikira dengan menolak bacaan meter sebelum dengan bacaan meter terkinl. Caj dikira berdasarkan kadar yang dinyatakan di Jadual 2.Sampel keluaran ditunjukkan di Rajah 16 Table 2 Jadual 2 First Rate RM 0.10 for first 500 units RM 0.25 for first 1000 units RM 0.50 for first 1500 units User Code User Type Household Office Industry Second Rate RM 0.25 for the following units RM 0.50 for the following units RM 0.75 for the following units 1 2 3 The program should include the following functions: [Aturcara perlu mengandungi fungsi-fungsi berikut:] (a) int calculateUsage (int previous_reading, int current_reading) that accepts value of previous reading and current reading of water consumption and return their difference Ant calculateUsage (int previous_reading, int current_reading) yang menerima nilai bacaan sebelum dan terkini penggunaan air dan memulangkan nilai perbezaan mereka) (b)void calculateCharge (int user_code, int usage, float charges) accepts user code, water usage and, calculate and return by reference the charges. Charges rate depends on the user code. [void calculateCharge (int user_code, int usage, float *charges) yang menerima kod pengguna, penggunaan air dan, mengira dan memulangkan alamat caj. Kadar caj beergantung kepada kod pengguna (c)void printBill (float charges) accepts and prints charges [void printBill(float charges) menerima dan mencetak caj. Sample output: Please enter Previous reading: 325682 Current reading: 384511 Please enter user code: 1 HOUSEHOLD consumption is 58829 units. Total charge for this month is: RM 14632.25 Figure 16 Rajah 16] (20 Marks/Markah)