Write a program that will compute water bill
You don't say what programming language you're using, so I can't give you a finished program. I wouldn't anyway since you should do your own homework. But here's a suggestion for how to do it.
All the program needs to do is make some simple calculations. Your total bill will be determined by how much water you've used, based on whatever price per unit the supplier charges. If the program is very simple, you can just assign a rate, prompt for the user to input the amount of water used, do the calculation and display the result.
A more complex, real-world billing program will need to do more calculations, but it's all simple adjustment. There may be different rates used for commercial customers and residential users. The rate may vary depending on how much water was used during the billing cycle. There may be fees added (sewage treatment, for instance), and these may be flat charges or depend on water usage. You'll probably have taxes to add in as well, possibly several levels (local, state, etc.). You will need to get all this information in to the program, either assigning the values to constant variables, taking it from the user during the program, or calculating it as necessary.
But basically all your program will need to do is the calculation total bill = water used * rate + all other costs.
How fancy the program needs to be is up to you, based on the requirements set out by your instructor. It may simply display total bill amount on the screen. Or you may need to format and print a paper bill with all the information, like a real supplier would send out. Good luck, and thanks for using Fixya!
Mar 12, 2011 |
Microsoft Computers & Internet