#include <iostream>
using namespace std;
//Program Description
//This program will output charges for customers. It will also output
//the total amounts used and total revenue recieved for the amounts.
int main()
{
//Constants
const double water1 = 0.60;
const double water2 = 0.40;
const double water3 = 0.32;
const double electric1 = 0.05;
const double electric2 = 0.03;
const double electric3 = 0.04;
const double electric4 = 0.06;
const double gas1 = 1.50;
const double gas2 = 1.40;
const double gas3 = 1.55;
const double water_minimum = 3.00;
const double electric_minimum = 7.00;
const double gas_minimum = 6.00;
//Variables
int cust_number;
char code;
int water;
int electric;
int gas;
double water_charge;
double electric_charge;
double gas_charge;
double total_bill;
int total_water;
int total_electric;
int total_gas;
double total_water_revenue;
double total_electric_revenue;
double total_gas_revenue;
double total_revenue;
int num_customers;
//Begin Program
//Initialize Totals
num_customers = 0;
total_water = 0;
total_electric = 0;
total_gas = 0;
total_water_revenue = 0;
total_electric_revenue =0;
total_gas_revenue = 0;
//Loop to read, process and report each customer
cout << "Enter Customer Number. 0 ends the input." << endl;
cin >> cust_number;
while (cust_number !=0)
{
cout << "Enter customer code, water used, and electric used.";
cout << endl;
cin >> code >> water >> electric;
if (code = "G")
{
cout << "Enter gas." << endl;
cin >> gas;
}
//Calculate water charge
if (water <= 10000)
water_charge = water/100*water1;
else if (water <= 100000)
water_charge=100*water1+(water-10000)/100*water2;
else
water_charge=100*water1+900*water2+(water-100000)/100*water3;
//Calculate electricity charge
if (electric <= 500)
electric_charge = electric * electric1;
else
if (electric <= 1500)
electric_charge = 500*electric1+(electric-500)*electric2;
else
electric_charge=500*electric1+1000*electric2+2000*
electric3
+(electric-3500)*electric4;
if (electric_charge < electric_minimum)
electric_charge = electric_minimum;
//Calculate gas charge
if (code == "G")
{
if (gas <= 50000)
gas_charge = gas/1000*gas1;
else
if (gas <= 100000)
gas_charge = 50*gas1+(gas-50000)/1000*gas2;
else
gas_charge = 50*gas1+50*gas2+(gas-100000)/1000*gas3;
if (gas_charge < gas_minimum)
gas_charge = gas_minimum;
else //code = "R"
gas = 0;
gas_charge = 0;
}
//Calculate total_bill
total_bill = water_charge + electric_charge + gas_charge;
//Report customer bill
cout << "CUSTOMER BILL" << endl;
cout << "Customer Number: " << cust_number << endl;
cout << "Water Used: " << water << endl;
cout << "Water Charge: " << water_charge << endl;
cout << "Electricity Used: " << electric << endl;
cout << "Electricity Charge: " << electric_charge << endl;
if (code == "G")
{
cout << "Gas Used: " << gas << endl;
cout << "Gas Charge: " << gas_charge << endl;
}
cout << "Total Bill: " << total_bill << endl;
//Update summary data
num_customers++;
total_water = total_water + water;
total_electric = total_electric + electric;
total_gas = total_gas + gas;
total_water_revenue = total_water_revenue + electric_charge;
total_gas_revenue = total_gas_revenue + gas_charge;
//Read the next customer number
cout << "Enter next customer number " << endl;
cin >> cust_number;
} //End of looping for each individual customer
//Report summary data for all customers
total_revenue = total_water_revenue + total_electric_revenue +
total_gas_revenue;
cout << "SUMMARY OF CUSTOMERS" << endl;
cout << "Number of Customers: " << num_customers << endl;
cout << "Total Water Used: " << total_water << endl;
cout << "Total Water Revenue: " << total_water_revenue << endl;
cout << "Total Electricity Used: " << total_electric << endl;
cout << "Total Electricity Revenue: " << total_electric_revenue << endl;
cout << "Total Gas Used: " << total_gas << endl;
cout << "Total Gas Revenue: " << total_gas_revenue << endl;
cout << "Total Revenue: " << total_revenue << endl;
return 0;
}
Okay, so I fixed those errors, but now I get these errors*.
prog12.cpp: In function `int main()':
prog12.cpp:72: error: ISO C++ forbids comparison between pointer and integer
prog12.cpp:99: error: ISO C++ forbids comparison between pointer and integer
prog12.cpp:125: error: invalid conversion from `const char*' to `char'
*Note: Line 158 is the very last line.