#include <stdio.h>
#include <conio.h>
int main() {
int id;
char name[80];
double totConsump;
char code;
double bills;
printf("Enter an ID of a subscriber: ");
scanf("%d", &id);
printf("Enter a name of the subscriber: ");
scanf("%s", name);
printf("Enter total electrical consumption in a month: ");
scanf("%lf", &totConsump);
printf("Enter a code of the consumer type: ");
code = getch();
if (code == 'R') {
bills = 50 + 0.50*totConsump;
}
else if (code == 'C') {
bills = 100;
if (totConsump > 1000) {
bills += 0.45*(totConsump - 1000);
}
}
else if (code == 'I') {
bills = 180;
if (totConsump > 1000) {
bills += 0.75*(totConsump - 1000);
}
}
else {
printf("Incorrect code: %c\n", code);
return 1;
}
printf("\n\n===========================\nElectric Company\n");
printf("Bill for %s ID: %06d\n", name, id);
printf("Total month consumption %.1f kwh; Total cost $%.2f\n",
totConsump, bills);
return 0;
}
Comments
Leave a comment