Description
Minimal Submitted Files
You are required to turn in the following source file: assignment4.s
Objectives:
-write assembly language programs to:
-perform decision making using branch instructions.
-use syscall operations to display integers and strings on the console window
-use syscall operations to read integers from the keyboard.
Assignment Description:
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 “No bill to pay this month.\n”.
If a customer spent less than or equals to 250 KWH in a month, then the payment should be 25 dollars.
If a customer spent more than 250 KWH in a month of June, July, August, or September, then the bill amount is computed by:
bill amount= (KWH for the Month-250)/18 + 25;
If a customer spent more than 250 KWH in any other month, then the payment is compute by:
bill amount= (KWH for the Month-250)/20 + 25;
Then if the payment is greater than 0, it should print out the payment amount, along with its used KWH.
Name your source code file Assignment4.s.
The following shows how it looks like in a C program:
int newMeter; int oldMeter; int KWHforMonth; int month;
int billAmount; printf("Please enter the new electricity meter reading:\n");
//read an integer from a user input and store it in newMeter scanf("%d", &newMeter);
printf("Please enter the old electricity meter reading:\n");
//read an integer from a user input and store it in oldMeter scanf("%d", &oldMeter);
printf("Please enter a month to compute their electricity bill,\n"); printf("Use an integer between 1 and 12 (1 for January, etc.):\n");
//read an integer from a user input and store it in month scanf("%d", &month);
KWHforMonth = newMeter - oldMeter;
if (KWHforMonth <= 0) {
printf("No bill to pay this month.\n"); }
else {
//compute its bill if (KWHforMonth <= 250)
{ billAmount = 25;
} else if (KWHforMonth > 250 && month >= 6 && month <= 9)
{ billAmount = (KWHforMonth-250)/18 + 25;
} else
{ billAmount = (KWHforMonth-250)/20 + 25;
}
//print out the billAmount
printf("Your total bill amount for this month: %d dollar(s) for %d KWH\n", billAmount, KWHforMonth);
} //end of else
https://canvas.asu.edu/courses/56799/pages/assignment4-due-wednesday-september-9th-5pm?module_item_id=3410171 3/6
9/8/2020 Assignment4 – Due: Wednesday, September 9th, 5pm: CSE 230: Computer Org/Assemb Lang Prog (2020 Fall)
Here is a sample output (user input is in bold):
Please enter the new electricity meter reading:
15430
Please enter the old electricity meter reading:
15105
Please enter a month to compute their electricity bill,
Use an integer between 1 and 12 (1 for January, etc.):
5
Your total bill amount for this month: 28 dollar(s) for 325 KWH
———————————————–
Here is another sample output (user input is in bold):
Please enter the new electricity meter reading:
23705
Please enter the old electricity meter reading:
22190
Please enter a month to compute their electricity bill,
Use an integer between 1 and 12 (1 for January, etc.):
8
Your total bill amount for this month: 95 dollar(s) for 1515 KWH
———————————————–
Here is another sample output (user input is in bold): ———————————————–
Please enter the new electricity meter reading:
34525
Please enter the old electricity meter reading:
34291
Please enter a month to compute their electricity bill,
Use an integer between 1 and 12 (1 for January, etc.):
6
Your total bill amount for this month: 25 dollar(s) for 234 KWH
———————————————–
Here is another sample output (user input is in bold):
———————————————–
Please enter the new electricity meter reading:
53205
Please enter the old electricity meter reading:
53205
Please enter a month to compute their electricity bill, Use an integer between 1 and 12 (1 for January, etc.): 4
No bill to pay this month.