Write a program that will calculate and print out bills for the city water company, and write a test plan to test the program.
The water rates vary, depending on whether the bill is for home use (code H), commercial use (code C), or industrial use (code I).
No other codes should be accepted. Remember to define constants for all fixed values.
The water rates are computed as follows:
The program input will be the four-digit user account number, the type code, and if necessary, the number of gallons used.
The program should first explain the program to the user.
Then prompt for a 4-digit user account number (no leading zeros allowed) and error check that the value entered is valid (integer value that must be in the range of 1000 to 9999). Re-prompt until a valid value is entered. This input should be read and error checked from within the main function.
Then call a user-defined function that will:
Then call a user-defined function that will:
Then call a user-defined function that will:
The output should display: the plan chosen in words (not the calculation method), the number of gallons used, and the total amount of the bill. Display neatly with descriptive text.
After displaying the results, ask the user whether to execute the program again, and do so, as long as the user wishes to continue.
So at a minimum, the program should implement three separate functions (in addition to main), as described below:
Use of global variables is NOT allowed. The functions must use parameters to pass required data to each function. Remember to pass all input only parameters by VALUE, and pass all output parameters by REFERENCE.
As part of your submission for this week, you must write a test plan for this program (program 1). Your test cases should include all INPUTs you used for the test and what OUTPUT you expected. Submit your test plan as an MS Word document.
NOTE: No sample inputs or sample outputs will be given for program #1 this week, to allow you to develop your own tests for your test plan.
Write a modular program to convert 7-letter words to the corresponding telephone numbers that they represent. The letter to digit conversion will be as follows:
ABC = 2 DEF = 3 GHI = 4 JKL = 5
MNO = 6 PRS = 7 TUV = 8 WXY = 9
The letters entered can be either upper or lowercase. No digit corresponds to Q or Z, so those letters cannot be used in the phone number. Non-alphabetic characters cannot be used either. If a character is invalid, the program should also display an error message saying specifically what the error was. (NOTE: Before you discover an error, you may have already displayed some numbers. That is okay.)
First prompt the user for a 7-letter word. The program should read and process the characters one at a time. As you read each character, call functions to check that the character entered is valid, and if it is valid, to display the equivalent digit (Note: Be sure to display a dash at the correct location in the phone number, format: xxx-xxxx).
The program should also count the characters as you read them, through the end of the line or until an error is discovered. STOP processing the line as SOON as you discover an error (remember to read past all remaining characters before you loop to process the next word).
If the program IS able to convert all of the letters of the word correctly, check the length and display an error if the user's word is too long or too short saying so and that the phone number displayed is NOT valid.
Continue to prompt for words and convert them, until the user indicates s/he is done (your choice how).
This program should include at least two additional user-defined functions with parameters (not including main()).
Sample Run (after program description to user):
Enter word to convert (or # to exit): Flowers
Phone number is: 356-9377
Enter word to convert (or # to exit): BBB
Phone number is: 222
ERROR – phone number is too short!
Enter word to convert (or # to exit): ALLQUIT
Phone number is: 255
ERROR – Q is not allowed
Enter word to convert (or # to exit): XXXXXXXX
Phone number is: 999-99999
Error – phone number is too long!
Enter word to convert (or # to exit): #
HINT: When you consider how to break this program into functions, think about how program 1 was divided up.
Remember to pass all input only parameters by value, and pass output parameters by reference when appropriate.