HELP!! EMERGENCY!!!

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!
Post what you have a question about and the code in question.
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.
Ok, please note, I know I do not have all brackets included currently..
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
using namespace std;

int main()
{
	// local constants
	int ELEC_USAGE_TIER1 = 700;									// Electricity usage for tier 1 (first 700 KWH used)
	int ELEC_USAGE_TIER2AND3 = 1500;							// Electricity usage for tier 2 & 3 (tier 2 = up to 1500, tier 3 = over 1500)
	double ELEC_RATE_TIER1 = 0.059;								// Electricity rate for tier 1 (first 700 KWH used)
	double ELEC_RATE_TIER2 = 0.065;								// Electricity rate for tier 2 (next 800 KWH used)
	double ELEC_RATE_TIER3 = 0.073;								// Electricity rate for tier 3 (additional KWH over 1500 KWH)
	int WATER_USAGE_TIER1 = 8000;								// Water usage for tier 1 (used less than 8,000 gallons)
	int WATER_USAGE_TIER2AND3 = 15000;							// Water usage for tier 2 & 3 (tier 2 = less than 15000, tier 3 = more than 15000)
	double WATER_RATE_TIER1 = 0.0021;							// Water rate for tier 1 (used less than 8,000 gallons)
	double WATER_RATE_TIER2 = 0.0029;							// Water rate for tier 2 (used at least 8,000 but less than 15,000 gallons)
	double WATER_RATE_TIER3 = 0.0040;							// Water rate for tier 3 (used at least 15,000 gallons)
	double SERVICE_FEE = 4.81;									// Service fee
	char RESIDENTIAL_UNIT = 'R';

	// local variables
	string customerCode;										// customer code containing 4 letters followed by 4 digits
	char customerStatus;										// customer status G for good, P for past due
	char unitType;												// unit type R for residential, B for business
	int electricityUsage;										// electricity usage representing the kilowatt hours (KWH) used
	int waterUsage;												// water usage representing the number of gallons used
	double perUnitCharge;										// utility charge per unit
	double totalElectricity;									// total cost of electricity usage
	double totalWater;											// total cost of water usage
	ifstream utility;											// input stream variable for UTILITY
	ofstream units;												// output stream variable UNITS
	ofstream customers;											// output stream variable CUSTOMERS

	utility.open ("UTILITY.txt");

	if (!utility)
	{
		cout << "Unable to open files." << endl;
		cout << "Program terminates." << endl;
		return 1;
	}

	units.open ("UNITS.txt");
	units << fixed << showpoint;
	units << setprecision (2);

	customers.open ("CUSTOMERS.txt");
	customers << fixed << showpoint;
	customers << setprecision (2);

	while (utility)
	{
		utility >> customerCode;
		utility >> customerStatus;
		
		while (utility.peek() != '\n')
		{
			utility >> unitType;
			utility >> electricityUsage;
			utility >> waterUsage;

			if (electricityUsage <= ELEC_USAGE_TIER1)
			{
				totalElectricity = electricityUsage * ELEC_RATE_TIER1;
			} 
			else if (electricityUsage <= ELEC_USAGE_TIER2AND3)
			{
				totalElectricity = electricityUsage * ELEC_RATE_TIER2;
			}
			else
			{
				totalElectricity = electricityUsage * ELEC_RATE_TIER3;
			}

			if (waterUsage < WATER_USAGE_TIER1)
			{
				totalWater = waterUsage * WATER_RATE_TIER1;
			}
			else if (waterUsage < WATER_USAGE_TIER2AND3)
			{
				totalWater = waterUsage * WATER_RATE_TIER2;
			}
			else
			{
				totalWater = waterUsage * WATER_RATE_TIER3;
			}
			
	perUnitCharge = totalElectricity + totalWater;

	units << unitType << setw (8) << perUnitCharge << endl;

	customers << customerCode;

	system ("PAUSE");
}


And, what's your question?
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.

NO ARRAYS AND NO OOP!
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.
I'll be honest, im completely lost right now...
Topic archived. No new replies allowed.