Hey everyone,
I have an assignment due for a programming class I am taking...I have done some of it...but there is so much I confused about. Please note: I DO NOT WANT YOU TO DO THE ASSIGNMENT FOR ME!!! I want and NEED to learn this material, but I do need someone to help walk me through a few parts that are killing me right now. If anyone has some free time, please let me know...I would like to email you what i have so far, as long as the assignment and where i am confused to see if you could help.
Thanks!
We can definitely help you here. If your code is very long, I suggest using pastebin.com, otherwise, once you paste your code here, highlight it and click on the formatting tags to the right that look like "< >" and it will correctly format it for you. Give use any errors you're having, what specifically you're stuck on, or whatever else would help us point you into the right direction.
All-American City, USA has collected information about monthly utility bills.
Data collected for billed units includes:
• customer code and customer status
• unit type for each utility bill
• electricity and water usage figures for each utility bill
Each line in the UTILITY.TXT data file contains a customer code and a customer status, followed by a list with the unit type, electricity used, and water used (three pieces of data for each unit), for each unit owned
by the customer.
• The customer code is a string, containing 4 letters followed by 4 digits
• The customer status is a character: G for good standing or P for past due
• For each unit owned by the customer,
o The unit type is a character: R for residential or B for business
o The electricity usage is an integer representing the kilowatt hours (KWH) used
o The water usage is an integer representing the number of gallons used
Write a program to process any data file that meets the above criteria. You will need to create your own data file (using a text editor, such as Notepad) to be used in testing your program during development. Your
facilitator will use his/her own data file to test your program.
Sample UTILITY.TXT data lines:
JOHN1234 G R 1812 18000 B 1738 9300 B 504 4500
GARC5678 P R 862 17000
JEFF9445 G B 1405 14300 B 712 5900
The program will analyze the utility data file and produce several reports. Your program may assume all data in the input file is valid data (i.e. formatted correctly), and therefore does not require input data
validation. However, the program must verify that the UTILITY.TXT input file exists (i.e. can be opened).
If the file does not exist, the program must issue an error message explaining what file could not be opened, pause for the user to read the error message, and then exit gracefully.
If the file exists, the program will read data from the file line by line, and calculate the utility charges collected for each unit, as the data is read.
Both electricity and water charges are calculated on a sliding scale, but using different methods.
For electricity, there are 3 tiers, each with separate charges, depending upon usage. Charges go up for every additional KWH used. Here are the formulas for calculating the electricity charges:
Usage Rate per KWH within tier
Tier 1: First 700 KWH used $ 0.059
Tier 2: Next 800 KWH used $ 0.065
Tier 3: Additional KWH over 1500 KWH $ 0.073
For water usage, charges for all water usage are based upon the highest total usage:
Usage Rate per Gallon for ALL water usage
Used less than 8,000 gallons $ 0.0021
Used at least 8,000 gallons,
and less than 15,000 gallons $ 0.0029
Used at least 15,000 gallons $ 0.0040
Residential units are charged a $4.81 service fee, and business units are charged a service fee that is twice
the residential unit fee.
You must define constants for all fixed values (including fees, usage level limits, and rate values).
As you read each line and calculate the utility charges:
• For each unit on the data line:
Calculate the total utility charge for the unit. Then output the unit type and utility charge to
one line of the text file UNITS.TXT
As you calculate the charges for each unit on one data line (i.e. for one customer), keep track of the
number of units owned by the customer, and the total utility charges for the customer.
• For each customer (i.e. after reading one entire line of data):
Output the customer code and the total utility charges for that customer to one line of the
text file CUSTOMERS.TXT
Output the customer code, the number units owned by the customer, and the total utility
charges for that customer to the display screen (along with identifying column headers at the
top of each column).
If the customer is past due, display the fact at the end of the display screen line
When outputing data to the display screen, keep track of the lines displayed to the screen.
Before displaying each line, check to see if the screen is full ("full" means approximately 20
lines have been displayed on the screen). The display should pause after each screen full of
data has been printed, so the user can read the information without it scrolling. Then the
column headers should be re-displayed, before displaying the next line of customer data.
As you calculate the total charges for each customer, keep track of grand total of all utility charges
for all customers/units in the data file.
After all lines in the file have been read and all the customer summaries have been displayed, output a
grand total of all the utility charges collected by the city to the display screen.
NOTE: The program should recognize the end of file correctly, whether the last line in the file
contains an end-of-line character or not (i.e. whether the data file ends at the end of the last line of
data, or on the next blank line).
HINT: Be sure to use the priming read in your code.
Sample output to the file UNITS.TXT:
R 192.89
B 147.26
:
: : indicates not all records in the file are shown here
B 138.22
B 64.09
Sample output to the file CUSTOMERS.TXT:
JOHN1234 388.96
GARC5678 124.64
JEFF9445 202.31
Notes for both output files :
• There should be NO spaces in front of the customer code or the unit type
• The decimals in the utility charges column should line up on the decimal point
• NO headers or descriptions should be included.
Sample output to the Display Screen:
Customer Units Utility
Code Owned Charges
-------- ------ -----------
JOHN1234 3 $ 388.96
GARC5678 1 $ 124.64 **PAST DUE
JEFF9445 2 $ 202.31
-----------
Total City Collected $ 715.90
Press any key to continue...
Notes for display screen output:
• All utility charges decimal points should line up.
• Column headers should be re-displayed after each pause, for each new screen full of data.
• The decimal point for the grand total collected by the city should line up with the decimal points of
all utility charges in the list above it.
My issue currently:
I cannot figure out how to get the perUnitCharge to print to the UNITS.txt after EVERY UNIT...see as how some customers have one unit, others have numerous units...the UNITS.txt wants me to print the utility charge for every unit, whereas CUSTOMERS.txt wants me to print the grand total per customer of all of their units. I can't figure out how to do that.