Program language dev C++
proposes to compute the water expenses
note Dis code is open source you can edit the code as lone you want but
do note remove the copyright comment in the code thank you
*for Educational purposes only
code below
note dont forget the brace in #include iostream
**********************************************************************************
#include iostream
using namespace std;
//code by John GErald Catague
//visit http://cataguegerald.blogspot.com for more info
float computeBill(char, float);
int main ()
{
int accountNo;
char useCode;
float gallons;
float amountDue;
cout << "Please enter your account number:";
cin >> accountNo;
cout << "\n*************************************************************\n";
cout << "\nEnter \nH for Home\nC for commercial\nI for industrial";
cout << "\n\nPlease enter your use code:";
cin >> useCode;
if ((useCode == 'H' || useCode == 'h'))
{
cout << "\n***************** User Type[Home] ***************************\n\n";
}
if ((useCode == 'C' || useCode == 'c'))
{
cout << "\n***************** User Type[Commercial] *********************\n\n";
}
if ((useCode == 'I' || useCode == 'i'))
{
cout << "\n***************** User Type[Industrial] *********************\n\n";
}
cout << "Please enter the number of gallons you used:";
cin >> gallons;
if ((useCode == 'H' || useCode == 'h'))
{
cout << "\n\n***************** REPORT for User[Home ]*******************\n";
}
if ((useCode == 'C' || useCode == 'c'))
{
cout << "\n\n***************** REPORT for User[Commercial]**************\n";
}
if ((useCode == 'I' || useCode == 'i'))
{
cout << "\n\n***************** REPORT for User[Industrial]]*************\n";
}
amountDue = computeBill(useCode, gallons);
cout << "Account Number: " << accountNo << endl;
cout << "Use Code: " << useCode << endl;
cout << "Gallons Used: " << gallons << endl;
cout << "The Bill is: " << amountDue << endl;
system ("pause");
return 0;
}
float computeBill(char useCode, float gallons)
{
if ((useCode == 'H' || useCode == 'h') && (gallons <= (float)1000000))
{
return 2250.00;
}
if ((useCode == 'H' || useCode == 'h') && (gallons > (float)1000000))
{
return ((gallons - 1000000) * 0.002) + 2250;
}
if ((useCode == 'C' || useCode == 'c') && (gallons <= (float)4000000))
{
return 5000.00;
}
if ((useCode == 'C' || useCode == 'c') && (gallons > (float)4000000))
{
return ((gallons - 4000000) * 0.002) + 5000;
}
if ((useCode == 'I' || useCode == 'i') && (gallons <= (float)4000000))
{
return 5000.00;
}
if ((useCode == 'I' || useCode == 'i') && (gallons > (float)4000000))
{
return 10000.00;
}
if ((useCode == 'I' || useCode == 'i') && (gallons <= (float)10000000))
{
return 10000.00;
}
if ((useCode == 'I' || useCode == 'i') && (gallons > (float)10000000))
{
return 15000.00;
}
}
+********************************************************************************
That's nasty piece of code! We are currently creating a software with a wisp billing system, this is really of great help to us. Thanks!
ReplyDelete