Question: Write a MIPS assembly language program that reads a customer's current and previous meter readings of electricity and a month to compute its electricity bill.

Write a MIPS assembly language program that reads a customer's current and previous meter readings of electricity and a month to compute its electricity bill. If a customer spent 0 or less (technically this should not happen, though) KWH (kilowatt-hours) that is computed by current meter reading - previous meter reading, then the program should print out "There is no bill to pay. ". If a customer spent less than or equals to 300 KWH in a month, then the payment should be 20 dollars. If a customer spent more than 300 KWH in a month of May, June, July, August, or September, then the payment is computed by: payment = 20 + (used KWH - 300) / 15; If a customer spent more than 300 KWH in any other month, then the payment is compute by: payment = 20 + (used KWH - 300) /20; Then if the payment is greater than 0, it should print out the payment amount, along with its used KWH

The following shows how it looks like in a C program:

int currentMeter; int previousMeter; int usedKWH; int month; int payment; printf("Please enter the current electricity meter reading: "); //read an integer from a user input and store it in currentMeter scanf("%d", ¤tMeter); printf("Please enter the previous electricity meter reading: "); //read an integer from a user input and store it in previousMeter scanf("%d", &previousMeter); printf("Please enter a month to compute their electricity bill, "); printf("Use an integer between 1 and 12 (1 for January, etc.): "); //read an integer from a user input and store it in month scanf("%d", &month); usedKWH = currentMeter - previousMeter; if (usedKWH <= 0) { printf("There is no bill to pay. "); } else { //compute its bill if (usedKWH <= 300) { payment = 20; } else if (usedKWH > 300 && month >= 5 && month <= 9) { payment = 20 + (usedKWH-300)/15; } else { payment = 20 + (usedKWH-300)/20; } //print out the payment printf("Your total payment for this month: %d dollar(s) for %d KWH ", payment, usedKWH); } //end of else 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!