#include <iostream>
#include <iterator>
#include <map>
#include <string>
using namespace std;
int main()
{
string TDU;
double usage;
double total_charge;
int run = 1;
map<string, double> monthlycharges;
monthlycharges.insert(pair<string, double>("ONCOR", 3.42));
monthlycharges.insert(pair<string, double>("CENTERPOINT ENERGY", 5.47));
monthlycharges.insert(pair<string, double>("AEP TEXAS CENTRAL", 9.00));
monthlycharges.insert(pair<string, double>("AEP TEXAS NORTH", 10.53));
monthlycharges.insert(pair<string, double>("TEXAS - NEW MEXICO POWER", 7.85));
map<string, double> kwhcharges;
kwhcharges.insert(pair<string, double>("ONCOR", 3.8447));
kwhcharges.insert(pair<string, double>("CENTERPOINT ENERGY", 4.03120));
kwhcharges.insert(pair<string, double>("AEP TEXAS CENTRAL", 4.84460));
kwhcharges.insert(pair<string, double>("AEP TEXAS NORTH", 4.01990));
kwhcharges.insert(pair<string, double>("TEXAS - NEW MEXICO POWER", 4.83210));
while (run == 1) {
cout << "Enter the name of TDU: " << endl;
std::getline(std::cin >> std::ws, TDU);
cout << "Enter the usage in kWh used: " << endl;
cin >> usage;
map<string, double>::iterator it_monthlycharges;
map<string, double>::iterator it_kwhcharges;
it_monthlycharges = monthlycharges.find(TDU);
it_kwhcharges = kwhcharges.find(TDU);
total_charge = it_monthlycharges->second + (it_kwhcharges->second * 0.01 * usage);
cout << "TDU Delivery charges for " << TDU << " : " << total_charge << endl;
cout << "Enter 1 to calculate bill for another month, 0 to exit" << endl;
cin >> run;
}
return 0;
}
This seems to work, though It is sloppy after I read some of your comments. Ill work on it .
But for some reason it won't run on my VS, but will run on the web.