Untitled
unknown
plain_text
21 days ago
1.6 kB
4
Indexable
Never
#include <stdio.h> int main() { int consumer_number, meter_number, previous_reading, current_reading; char consumer_name[50]; float total_bill; printf("Enter Consumer Number: "); scanf("%d", &consumer_number); printf("Enter Consumer Name: "); scanf("%s", consumer_name); printf("Enter Meter Number: "); scanf("%d", &meter_number); printf("Enter Previous Meter Reading: "); scanf("%d", &previous_reading); printf("Enter Current Meter Reading: "); scanf("%d", ¤t_reading); int units_consumed = current_reading - previous_reading; if (units_consumed <= 100) { total_bill = units_consumed * 2.0; } else if (units_consumed <= 200) { total_bill = 100 * 2.0 + (units_consumed - 100) * 3.0; } else if (units_consumed <= 300) { total_bill = 100 * 2.0 + 100 * 3.0 + (units_consumed - 200) * 4.50; } else if (units_consumed <= 500) { total_bill = 100 * 2.0 + 100 * 3.0 + 100 * 4.5 + (units_consumed - 300) * 5.50; } else { total_bill = 100 * 2.0 + 100 * 3.0 + 100 * 4.5 + 200 * 5.5 + (units_consumed - 500) * 7.0; } printf("\nElectric Bill\n"); printf("Consumer Number: %d\n", consumer_number); printf("Consumer Name: %s\n", consumer_name); printf("Meter Number: %d\n", meter_number); printf("Previous Reading: %d\n", previous_reading); printf("Current Reading: %d\n", current_reading); printf("Units Consumed: %d\n", units_consumed); printf("Total Bill: Rs. %.2f\n", total_bill); return 0; }
Leave a Comment