#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:
Comments
I need in C progrm not C++...I used this coding it doesnt run'.
Leave a comment