• Language

    C

  • Description

    It calculates the water consumption and the amount payed for water consumption including VAT 18%
    0m³ - 5m³ = 143 Rwf/m³
    6m³ - 15m³ = 244 Rfw/m³
    16m³ - 40m³ = 374 Rfw/m³
    41m³ and over = 740 Rfw/m³

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <stdio.h>
#include <stdlib.h>

int main (void)
{
    float VAT, amount, amount_per_m3, sub_amount, water_consumption_in_m3;
    printf ("Enter the value of water consumption in m3: ");
    scanf ("%f", &water_consumption_in_m3);
    (void) getchar ();
    amount_per_m3=0;
    if(water_consumption_in_m3<6)
        amount_per_m3=143;
    if(water_consumption_in_m3>=6&&water_consumption_in_m3<16)
        amount_per_m3=244;
    if(water_consumption_in_m3>=16&&water_consumption_in_m3<41)
        amount_per_m3=374;
    if(water_consumption_in_m3>=41)
        amount_per_m3=740;
    sub_amount=amount_per_m3*water_consumption_in_m3;
    VAT=sub_amount*0.18;
    amount=sub_amount+VAT;
    printf ("Value of VAT: %g\n", VAT);
    printf ("Value of amount: %g\n", amount);
    printf ("Value of amount per m3: %g\n", amount_per_m3);
    printf ("Value of sub amount: %g\n", sub_amount);
    putchar ('\n');
    system ("pause");
    return EXIT_SUCCESS;
}