Answer to Question #149658 in C for Kavisshna

Question #149658
Calculate the water consumption bill industry
1
Expert's answer
2020-12-09T22:52:49-0500
#include <stdio.h>


int main() {
    int account;
    char code;
    double bill;
    double gallons = 0;

    printf("Enter your account number:");
    scanf("%d", &account);

    printf("Now enter your code(h,c, or i):");
    scanf("%s", &code);

    printf("Now enter the amount of gallons of water used:");
    scanf("%lf", &gallons);

    if (code == 'h') {
        bill = 5 + (gallons * 0.0005);
    }
    if (code == 'c' && gallons > 4000000) {
        bill = 1000 + ((gallons - 4000000) * 0.00025);
    } else if (code == 'c' && gallons <= 4000000) {
        bill = 1000;
    }
    if (code == 'i' && gallons <= 4000000) {
        bill = 1000;
    } else if (code == 'i' && gallons < 4000000 && gallons >
                                                   10000000) {
        bill = 2000;
    } else if (code == 'i' && gallons >= 10000000) {
        bill = 3000;
    }

    printf("The bill for account number: %d , will be: %f$", account, bill);


}



OUTPUT:

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Kavisshna
09.12.20, 08:23

I need in C progrm not C++...I used this coding it doesnt run'.

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS