Project 6

Due: 5 Dec

Requirements Specification

Write the C code for billing a customer for power comsumption. Use functions to do this project.

Your program should do the following and must have the following functions:

  1. Compute the bill for a customer depending on the power consumed.
  2. Fixed price for less than 100KWh. (inclusive).
  3. Fixed price for the first 100 KWh. (inclusive) and some rate per KWh. for more that 100KWh. and upto 200KWh. (inclusive).
  4. Same as 3 and some rate per KWh for more than 200KWh. and upto 300 KWh. (inclusive).
  5. Same as 4 and some fixed price for usage above 300KWh.
  6. GetRates :- Get the fixed price for upto 100KWh., rate/KWh. for 100 upto 200KWh., rate/KWh. for 200 upto 300KWh. and fixed price for above 300KWh. Error check to make sure each value entered is greater than zero. Should be able to get decimals as input.
  7. CalculateBill :- Get a usage value and calculate the bill. Error check to make sure that usage is not negative. Print the total bill amount.
  8. GetOptions :- Get the option R for entering new rates, B for billing using previously entered rates and Q for quitting. Do error checking to make sure that the options are correct.


The functions should have the names mentioned above. Also the program should keep asking for options unless the user wants to quit. If the rates are not
entered for the first time and the user asks to bill ask for the rates before billing (use GetRates to do this).

Name the source code file: proj6.c

Submission

Email the source file (the .c file) as an attachment to the TA at dipesh1@umbc.edu.

The subject of the email should be "CMSC104 Section 0701 Project 6". This must be an exact match for the TA to be able to filter the mail and put your work in the correct folder! Write your name, last four digits of your social security number and your section number in the body of the email. Please follow all this instructions and make sure that you have met them before sending the email. Don't send a copy to me. You will lose points if you don't follow the instructions.

Example Output

In the following example, the program displays what is in Blue and the user types what is in Red.

Enter R to enter rates, B for billing and Q to quit.
Enter Selection: B
Rates not entered. Please enter the rates first.
Fixed Rate (upto 100KWh.) : 100.00
Rate/KWh. (100 upto 200 KWh.) : 1.20
Rate /KWh. (200 upto 300 KWh.) : 1.50
Fixed Rate (above 300 KWh.) : 250.00
Enter usage in KWh. : 125
Total bill is $130.00
Enter R to enter rates, B for billing and Q to quit.
Enter Selection: B
Enter usage in KWh. : 450
Total bill is $620.00
Enter R to enter rates, B for billing and Q to quit.
Enter Selection: R
Fixed Rate (upto 100KWh.) : 100.00
Rate/KWh. (100 upto 200 KWh.) : 1.30
Rate /KWh. (200 upto 300 KWh.) : 1.70
Fixed Rate (above 300 KWh.) : 300.00
Enter R to enter rates, B for billing and Q to quit.
Enter Selection: B
Enter usage in KWh. : 50
Total bill is $100.00
Enter R to enter rates, B for billing and Q to quit.
Enter Selection: Q
Quitting!!

-- Remember the program keeps on asking for options unless the user wants to quit.

Program Header Comment Block

Use the following comment block at the beginning of your source code:
/* 
** Filename:       proj6.c
** Name:           Your name
** SSAN:           Last four digits of your SSN   
** Date:           Date of submission
** Course:         CMSC-104 Section XXX 
** Description:    (Your psuedocode goes here.  Must be detailed)
** Notes:          (As needed, such as how to compile)
*/


You will lose points if you don't follow the instructions for the Header Comment Block.