# NEED HELP

KING KONG ELECTRICITY AUTHORITY
BILL CALCULATOR
You are required to develop a script that will enable KING KONG ELECTRICITY AUTHORITY to
calculate customer bills based on their meter readings.
The customers are categorized into the following categories:
? Residential customers
? Commercial customers
Residential tariff rates
If the units of power consumed is less than or equal to (<=) 75 kW per month, the government
will subsidize at the rate of 17.64 cents per unit for all consumptions equal to or less than
75kW per month and in effect the customer will pay 17.20 cents per unit.
If the units of power consumed are greater than (>) 75 kW per month, the user is not entitled
for government subsidy. All consumptions will be charged at the rate of 34.84 cents per unit.
Commercial tariff rates
If the units of power consumed is less than or equal to (<=) 14,999 kW per month, the
consumer is charged at 42 cents per unit. The excess units will be charged at 44 cents per unit
and added to the overall total.
Program flow:
The following are the inputs to the program:
1. Client name
2. Client address
3. Client category (

## Comments

• [code]#include
#include
using namespace std;

struct Client {
string name;
string address;
char category;
string date;
string startMonth;
string endMonth;
int previousReading;
int currentReading;
};

void readInput(Client&);
double computeReading(Client);

/*
*
*/
int main(int argc, char** argv) {
Client client;
readInput(client);
double amount = computeReading(client);
double vat = amount * 0.15;
cout << "

Total bill (VEP): \$" << amount <<endl <<endl;
cout << "Total VAT(15%): \$" << vat << endl << endl;
cout << "Total billing (VEP) + (VAT): \$" << amount + vat << endl;

return 0;
}
void readInput(Client& client) {
cout << "Enter Client Name: ";
getline(cin,client.name);

cout << "Enter Client Address: ";
getline(cin,client.address);

cout << "Enter Client Category: ";
cin >> client.category;
cin.ignore();

cout << "Enter Date of Meter Reading (format dd/mm/yyyy): ";
getline(cin,client.date);

cout << "Enter Reading Start Month: ";
getline(cin,client.startMonth);

cout << "Enter Reading End Month: ";
getline(cin,client.endMonth);

cout << "Enter Previous Reading: ";
cin >> client.previousReading;

cout << "Enter Current Reading: ";
cin >> client.currentReading;
}

double computeReading(Client client) {
if (client.category == 'R') {
if ((client.currentReading - client.previousReading) <= 75)
return (client.currentReading - client.previousReading) * 17.20;
else
return (client.currentReading - client.previousReading) * 34.84;
}
else if (client.category == 'C') {
if ((client.currentReading - client.previousReading) <= 14999)
return (client.currentReading - client.previousReading) * 0.42;
else {
int excess = (client.currentReading - client.previousReading) - 14999;
return (excess * 0.44) + (14999 * 0.42);
}

}
return 0.0;
}

[/code]
Sign In or Register to comment.

#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!