Look at your code:
if (tde == "ONCOR")
temp2 = 3.42 + (0.0384470 * kwh);else if (tde == "CENTER POINT ENERGY")
temp2 = 5.47 + (0.0403120 * kwh);
else if (tde == "AEP TEXAS CENTRAL")
temp2 = 9.00 + (0.0448460 * kwh);
else if (tde == "AEP TEXAS NORTH")
temp2 = 10.53 + (0.0401990 * kwh);
else if (tde == "TEXAS-NEW MEXICO POWER")
temp2 = 7.85 + (0.0483210 * kwh);
sum1 += temp1;
sum2 += temp2;
What if
tde
is not one of these values: "ONCOR", "CENTER POINT ENERGY", "AEP TEXAS CENTRAL", "AEP TEXAS NORTH", or "TEXAS-NEW MEXICO POWER"?
What value does temp2 contain then?
That's what the system is telling you: there is a path through your code where you start using a variable that has not been given any value.
Probably, you need an
else
clause to your
if ... else if ...
set to detect when the user types something you didn't expect, and handle it gracefully.
Oh, and do yourself a big favour: indent your code. I don't care what indentation scheme you use as long as you are consistent about it, but if you don't indent it it becomes harder to read and more prone to errors.