This document contains C++ code that generates utility billing statements by randomly generating customer and meter data, calculating usage amounts and charges, and outputting a formatted statement to a file. It includes functions to calculate bills for water, gas, electricity and totals. Customer name, address, previous balance, usage details and amount due are output to a text file for a utility billing statement.
Teksavers is a Leading Cisco Reseller in AustinChris Miller
The company is highly dedicated to the environment and follows complete eco-friendly practices in their businesses. They do not dump the products on the ground to save the environment.
This what Im suppose to do and this is what I have so far.In thi.pdfkavithaarp
This what I\'m suppose to do and this is what I have so far.
In this assignment you are to create an interactive line command driven C++ program that allows
a user to do the following:
Create a bank account by supplying a user id and password
Login using this id and password
Quit the program
Upon successful login, the user will be presented with a menu to do one or more of the following
actions:
Withdraw money
Deposit money
Request balance
Quit the program
Ensure that you remove any unnecessary punctuation from monetary input (for example, all $ or
other currency symbols should be removed prior to processing, do NOT display an error message
to the user for characters which can be removed from the input string without changing the
intended value).
Format all monetary outputs on the display Currency (e.g. $ 25,928.43) with all decimal places
containing digits.
The User ID and password fields may be any combination of characters which are:
Visible when displayed on the screen (no control characters0
Normally accessible from a standard US keyboard
#include
#include
#include
using namespace std;
class Howard_COP2513_F1601 {
public:
char userInput = \'?\';
char userInput2 = \'?\';
string id = \"carl\";
string password = \"jones\";
string ID = \"?\";
string PASSWORD = \"?\";
double DEPOSIT = 0.00;
double WITHDRAW = 0.00;
double OLDBALANCE = 0.00;
double NEWBALANCE = 0.00;
void bankOption() {
cout << \"Please select an option: \" << endl;
cout << \"l -> Login \" << endl;
cout << \"c -> Create New Account \" << endl;
cout << \"q -> Quit \" << endl;
cin >> userInput;
if (userInput == \'l\' || \'L\') {
login();
}
else if (userInput == \'c\' || \'C\') {
createAcnt();
}
else if (userInput == \'q\' || \'Q\') {
quit();
}
}
void moneyOption() {
cout << \"d -> Deposit Money \" << endl;
cout << \"w -> Withdraw Money \" << endl;
cout << \"r -> Request Balance\" << endl;
cin >> userInput2;
if (userInput2 == \'d\' || \'D\') {
dMoney();
}
else if (userInput2 == \'w\' || \'W\') {
wMoney();
}
else if (userInput2 == \'r\' || \'R\') {
rBalance();
}
}
int login() {
cout << \"Please enter your user id: \" << endl;
cin >> ID;
cout << \"Please enter your password: \" << endl;
cin >> PASSWORD;
if (id != ID && password != PASSWORD) {
cout << \"Access Granted - \" << ID << endl;
}
else {
cout << \"******** \" << \"LOGIN FAILED! \" << \"********\" << endl;
bankOption();
}
moneyOption();
return 0;
}
int createAcnt() {
cout << \"Please enter your user name: \" << endl;
cin >> ID;
cout << \"Please enter your password: \" << endl;
cin >> PASSWORD;
bankOption();
return 0;
}
int quit() {
cout << \"Thanks for banking with COP2513.F16,\";
system(\"pause\");
return 0;
}
int dMoney() {
cout << \"Amount of deposit: \" << endl;
cin >> DEPOSIT;
OLDBALANCE = NEWBALANCE;
NEWBALANCE = OLDBALANCE + DEPOSIT;
moneyOption();
return 0;
}
int wMoney() {
cout << \"Amount of withdrawal: \" << endl;
cin >> WITHDRAW;
OLDBALANCE = NEWBALANCE;
NEWBALANCE = OLDBALANCE - WITHDRAW;
moneyOption();
return 0;.
Teksavers is a Leading Cisco Reseller in AustinChris Miller
The company is highly dedicated to the environment and follows complete eco-friendly practices in their businesses. They do not dump the products on the ground to save the environment.
This what Im suppose to do and this is what I have so far.In thi.pdfkavithaarp
This what I\'m suppose to do and this is what I have so far.
In this assignment you are to create an interactive line command driven C++ program that allows
a user to do the following:
Create a bank account by supplying a user id and password
Login using this id and password
Quit the program
Upon successful login, the user will be presented with a menu to do one or more of the following
actions:
Withdraw money
Deposit money
Request balance
Quit the program
Ensure that you remove any unnecessary punctuation from monetary input (for example, all $ or
other currency symbols should be removed prior to processing, do NOT display an error message
to the user for characters which can be removed from the input string without changing the
intended value).
Format all monetary outputs on the display Currency (e.g. $ 25,928.43) with all decimal places
containing digits.
The User ID and password fields may be any combination of characters which are:
Visible when displayed on the screen (no control characters0
Normally accessible from a standard US keyboard
#include
#include
#include
using namespace std;
class Howard_COP2513_F1601 {
public:
char userInput = \'?\';
char userInput2 = \'?\';
string id = \"carl\";
string password = \"jones\";
string ID = \"?\";
string PASSWORD = \"?\";
double DEPOSIT = 0.00;
double WITHDRAW = 0.00;
double OLDBALANCE = 0.00;
double NEWBALANCE = 0.00;
void bankOption() {
cout << \"Please select an option: \" << endl;
cout << \"l -> Login \" << endl;
cout << \"c -> Create New Account \" << endl;
cout << \"q -> Quit \" << endl;
cin >> userInput;
if (userInput == \'l\' || \'L\') {
login();
}
else if (userInput == \'c\' || \'C\') {
createAcnt();
}
else if (userInput == \'q\' || \'Q\') {
quit();
}
}
void moneyOption() {
cout << \"d -> Deposit Money \" << endl;
cout << \"w -> Withdraw Money \" << endl;
cout << \"r -> Request Balance\" << endl;
cin >> userInput2;
if (userInput2 == \'d\' || \'D\') {
dMoney();
}
else if (userInput2 == \'w\' || \'W\') {
wMoney();
}
else if (userInput2 == \'r\' || \'R\') {
rBalance();
}
}
int login() {
cout << \"Please enter your user id: \" << endl;
cin >> ID;
cout << \"Please enter your password: \" << endl;
cin >> PASSWORD;
if (id != ID && password != PASSWORD) {
cout << \"Access Granted - \" << ID << endl;
}
else {
cout << \"******** \" << \"LOGIN FAILED! \" << \"********\" << endl;
bankOption();
}
moneyOption();
return 0;
}
int createAcnt() {
cout << \"Please enter your user name: \" << endl;
cin >> ID;
cout << \"Please enter your password: \" << endl;
cin >> PASSWORD;
bankOption();
return 0;
}
int quit() {
cout << \"Thanks for banking with COP2513.F16,\";
system(\"pause\");
return 0;
}
int dMoney() {
cout << \"Amount of deposit: \" << endl;
cin >> DEPOSIT;
OLDBALANCE = NEWBALANCE;
NEWBALANCE = OLDBALANCE + DEPOSIT;
moneyOption();
return 0;
}
int wMoney() {
cout << \"Amount of withdrawal: \" << endl;
cin >> WITHDRAW;
OLDBALANCE = NEWBALANCE;
NEWBALANCE = OLDBALANCE - WITHDRAW;
moneyOption();
return 0;.
1. #include<iostream>
#include<string>
#include<iomanip>
#include<fstream>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cmath>
#include<Windows.h>
using namespace std;
SYSTEMTIME*p_st=new SYSTEMTIME;
typedef unsigned long long Type;
Type myRand(const Type Max, const Type Min = 0)
{
return rand()/(float)RAND_MAX * (Max-Min) + Min ;
}
int main()
{
srand(time(0));
char sdate[9];
_strdate_s( sdate );
int number=rand()%999999+100000;
int customer=rand()%999999+100000;
int watermeter=rand()%99999999+10000000;
int gasmeter=rand()%99999+10000;
int electric=rand()%99999+10000;
int watermeter2=rand()%99999999+10000000;
int gasmeter2=rand()%99999+10000;
int electric2=rand()%99999+10000;
int watermeter3=rand()%99999999+10000000;
int gasmeter3=rand()%99999+10000;
int electric3=rand()%99999+10000;
int c=rand()%9999+1000;
int b=rand()%99999+10000;
int account=211012222222;
double avaicharge=0.00;
double previousbalance;
double payments=0.00;
double balance=0.00;
double water=17.08;
double gas=12.26;
double trash=16.50;
double tax=8.46;
double misc=0.44;
double total=280.00;
double gross=294.00;
double net=280.00;
bool arrangements;
int presentreadingwater=0;
int presentreadinggas=0;
int presentreadingelectric=0;
2. int presentreadingsewer=0;
int days=30;
int invnumber=rand()%99999+10000;
int invnumber2=rand()%999999+100000;
srand(unsigned(time(0)));
const Type MAX = 99999999999;
const Type MIN = 10000000000;
double consg;
double conse;
double chargee=8.88;
double consw;
double chonsw=3.84;
double watercons1=(3000*0.001240);
double watercons2=(3000*0.001550);
double watercons3=(2900*0.001680);
double avaichargewater=3.84;
double consgas=(800*0.009700);
double avaichargegas=4.50;
double avaichargeelectric=8.88;
double elecons1=(1400*0.082720);
double elecons2=(667*0.090730);
double electricbill(double chargee, double conse);
double gasbill(double consg);
double waterbill(double chonsw,double consw);
double sewercons=0.0045;
char input[7];
const char password[7]="jeremy";
GetSystemTime(p_st);
cout<<sdate<<endl;
cout<<"Please enter your password: "<<endl;
cin>>input;
if(strcmp(input,"jeremy")!=0)
{
cout<<"Invalid password"<<endl;
}
else
{
cout<<"Correct password"<<endl;
ifstream inFile;
ofstream outFile;
outFile.open("Utility2.dat",ios::out|ios::app);
cout<<"Please enter the gas usage: "<<endl;
cin>>consg;
cout<<gasbill(consg)<<endl;
cout<<"Please enter the electricity usage: "<<endl;
cin>>conse;
cout<<electricbill(chargee,conse)<<endl;
cout<<"Please enter you're water usage: "<<endl;
cin>>consw;
cout<<fixed<<showpoint<<setprecision(2)<<waterbill(chonsw,consw)<<endl;
3. cout<<"Please enter the customer's previous balance: ";
cin>>previousbalance;
if(previousbalance<0)
{
cout<<"Have any arrangements been made?";//answer in true or false
cin>>arrangements;
}
if(arrangements=true)
{
cout<<"Power is on";
}
else if(arrangements=false)
{
cout<<"A $30 fee has been added to turn your power back on";
}
outFile<<setw(18)<<"Customer Name";
outFile<<right<<setw(36)<<"Customer Number: "<<customer<<c<<endl;
cout<<right;
outFile<<setw(18)<<"UTILITY CUSTOMER"<<right<<setw(36)<<"Account Number:
"<<number<<b<<endl;
outFile<<right<<setw(36)<<"www.hsvutil.org";
outFile<<right<<setw(19)<<"Pay Gross After: "<<p_st->wMonth<<"/"<<p_st-
>wDay+10<<"/"<<p_st->wYear<<endl;
outFile<<right;
outFile<<setw(18)<<"Service Address"<<setw(35)<<"Net Amount Due:$
"<<fixed<<showpoint<<setprecision(2)<<gasbill(consg)+electricbill(chargee,conse)+waterbil
l(chonsw,consw)+sewercons+trash+misc+(gasbill(consg)+electricbill(chargee,conse)+waterbil
l(chonsw,consw)+sewercons+trash)-(previousbalance)*.03<<endl;
outFile<<endl;
outFile<<endl;
outFile<<"123 ANY STREET"<<endl;
outFile<<right<<setw(18);
outFile<<"HUNTSVILLE AL"<<setw(34)<<"Invoice Date: "<< p_st->wMonth<<"/"<<p_st-
>wDay<<"/"<<p_st->wYear<<endl;
outFile<<right<<setw(21)<<"|Bill due upon receipt. Data above applies to current
charges and not to previous balance. |"<<endl;
outFile<<right<<setw(18)<<"Messages"<<right<<setw(80)<<"|Account Summary
|"<<endl;
outFile<<right<<setw(64)<<"|Previous Balance
"<<right<<setw(17)<<"$"<<previousbalance<<right<<setw(13)<<"|"<<endl;
outFile<<"|*PUBLICLY-OWNED, NOT-FOR-PROFIT--RELIABLE
|Payments"<<right<<setw(26)<<"$"<<payments<<right<<setw(13)<<"|"<<endl;
outFile<<"SERVICES-LOWER RATES"<<right<<setw(42)<<"|Balance
Forward"<<right<<setw(27)<<"$"<<balance<<" |"<<endl;
outFile<<"Please be advised that your meter reading date"<<"|Current
Charge"<<endl;
outFile<<right<<setw(20)<<"Service Period: "<<right<<setw(27)<<"|"<<endl;
outFile<<"was May 5, 2011."<<right<<setw(37)<<"|Water "<<right<<setw(20)<<"$
"<<fixed<<showpoint<<setprecision(2)<<waterbill(chonsw,consw)<<endl;
outFile<<right<<setw(50)<<"|Gas"<<right<<setw(23)<<" $
"<<fixed<<showpoint<<setprecision(2)<<gasbill(consg)<<endl;
5. >wYear<<right<<setw(10)<<watermeter2<<right<<setw(5)<<p_st->wMonth<<"/"<<p_st-
>wDay<<"/"<<p_st->wYear<<right<<setw(13)
<<watermeter3<<right<<setw(7)<<days<<right<<setw(10)<<
consw<<right<<setw(26)<<consw<<" GAL|"<<endl;
outFile<<"------------------------------------------------------------------------
----------------------------------------------------"<<endl;
outFile<<right<<setw(70)<<"*********************FINAL
NOTICE*********************"<<endl;
outFile<<"This is to notify you that it may be necessary to discontinue your
utility service as of 05/24/11 unless prompt payment of this invoice or"<<endl;
outFile<<"satisfactory arrangement for payment is made before this date. Payment
in full or satisfactory payment arrangements made before"<<endl;
outFile<<"05/24/11 will avoid any reconnection or collection charges. If you have
any questions or disputes concerning your account, you should"<<endl;
outFile<<"contact us in person, by telephone at (256) 535-1200 or toll free at
(866) 478-8845 before 05/24/11. A review procedure is also available"<<endl;
outFile<<"to all our customers through which problems or disputes may be resolved;
copies are available at the utilities office. Call (256) 535-1200 to"<<endl;
outFile<<"make payment agreements by phone. Have your account number and pin
number available. No further notice will be provided."<<endl;
outFile<<endl;
outFile<<right<<setw(35)<<"Please return bottom portion with your payment."<<endl;
outFile<<"________________________________________________________________________
___________________________________________________"<<endl;
outFile<<right<<setw(30)<<"Account number "<<account<<right<<setw(30)<<"Pay Gross
After"<<right<<setw(17)<<p_st->wMonth<<"/"<<p_st->wDay+10<<"/"<<p_st->wYear<<endl;
outFile<<right<<setw(65)<<"Net Amount Due"<<right<<setw(18)<<"$
"<<fixed<<showpoint<<setprecision(2)<<gasbill(consg)+electricbill(chargee,conse)+waterbil
l(chonsw,consw)+sewercons+trash+misc+(gasbill(consg)+electricbill(chargee,conse)+waterbil
l(chonsw,consw)+sewercons+trash)-(previousbalance)*.03<<endl;
outFile<<endl;
outFile<<endl;
outFile<<right<<setw(55)<<"_______________________________________"<<endl;
outFile<<right<<setw(55)<<"|Total Amount Paid| |"<<endl;
outFile<<right<<setw(55)<<"| Project Share| |"<<endl;
outFile<<right<<setw(55)<<"---------------------------------------"<<endl;
outFile<<right<<setw(55)<<"HUNTSVILLE UTILITIES"<<endl;
outFile<<right<<setw(55)<<"HUNTSVILLE, AL 35895"<<endl;
outFile<<endl;
outFile<<right<<setw(18)<<"UTILITY CUSTOMER"<<endl;
outFile<<right<<setw(18)<<"123 ANY STREET"<<endl;
outFile<<right<<setw(18)<<"HUNTSVILLE AL 35803"<<endl;
outFile<<right<<setw(70)<<"Invoice Number: "<<invnumber<<invnumber2<<endl;
outFile<<endl;
outFile<<"Charge Details"<<endl;
outFile<<"Water-RWM-22/Residential Water HSV ("<<p_st->wMonth-1<<"/"<<p_st-
>wDay<<"/"<<p_st->wYear<<"-"<<p_st->wMonth<<"/"<<p_st->wDay<<"/"<<p_st->wYear<<", for 30
days)"<<endl;
outFile<<" Availability Charge"<<right<<setw(34)<<avaicharge<<endl;
outFile<<" Consumption Charge"<<right<<setw(30)<<"3000 GAL
@0.001240"<<right<<setw(8)<<"3.72"<<endl;
outFile<<right<<setw(49)<<"3000 GAL @0.001550"<<right<<setw(8)<<"4.65"<<endl;
outFile<<right<<setw(49)<<"2900 GAL
@0.001680"<<right<<setw(8)<<"4.87"<<right<<setw(9)<<"Total "<<waterbill(chonsw,consw);
outFile<<endl;
outFile<<"Gas-RGM-22/Residential Gas ("<<p_st->wMonth-1<<"/"<<p_st-
>wDay<<"/"<<p_st->wYear<<"-"<<p_st->wMonth<<"/"<<p_st->wDay<<"/"<<p_st->wYear<<", for 30
days)"<<endl;
6. outFile<<" Availability Charge"<<right<<setw(37)<<"4.50"<<endl;
outFile<<" Consumption Charge"<<right<<setw(31)<<"800 CUF
@0.009700)"<<right<<setw(9)<<consgas<<" Total $"<<gasbill(consg)<<endl;
outFile<<endl;
outFile<<"Electric-REM-22/Residential Electricity ("<<p_st->wMonth-1<<"/"<<p_st-
>wDay<<"/"<<p_st->wYear<<"-"<<p_st->wMonth<<"/"<<p_st->wDay<<"/"<<p_st->wYear<<", for 30
days)"<<endl;
outFile<<" Availability Charge"<<right<<setw(38)<<avaichargeelectric<<endl;
outFile<<" Consumption Charge"<<right<<setw(29)<<"1400
KWH@0.082720"<<right<<setw(11)<<elecons1<<endl;
outFile<<right<<setw(48)<<"667
KWH@0.090730"<<right<<setw(12)<<elecons2<<right<<setw(7)<<"Total
$"<<electricbill(chargee,conse)<<endl;
outFile<<"________________________________________________________________________
________"<<endl;
outFile<<"Sewer-RSM-22/Residential Sewer ("<<p_st->wMonth-1<<"/"<<p_st-
>wDay<<"/"<<p_st->wYear<<"-"<<p_st->wMonth<<"/"<<p_st->wDay<<"/"<<p_st->wYear<<", for 30
days) |"<<endl;
outFile<<" Sewer Consumption Charge"<<right<<setw(20)<<"8900
GAL@0.004500"<<right<<setw(11)<<sewercons<<"
Total"<<sewercons<<right<<setw(13)<<"|"<<endl;
outFile<<right<<setw(81)<<"|"<<endl;
outFile<<"Trash-RTU-22/Residential Trash HSV city ("<<p_st->wMonth-1<<"/"<<p_st-
>wDay<<"/"<<p_st->wYear<<"-"<<p_st->wMonth<<"/"<<p_st->wDay<<"/"<<p_st->wYear<<", for 30
days)"<<right<<setw(9)<<"|"<<endl;
outFile<<" Trash Charge"<<right<<setw(46)<<trash<<" Total $"<<trash<<endl;
outFile<<"------------------------------------------------------------------------
---------"<<endl;
outFile<<"Tax"<<right<<setw(60)<<(gasbill(consg)+electricbill(chargee,conse)+water
bill(chonsw,consw)+sewercons+trash)*.03<<" Total
$"<<(gasbill(consg)+electricbill(chargee,conse)+waterbill(chonsw,consw)+sewercons+trash)*
.03<<endl;
outFile<<endl;
outFile<<endl;
outFile<<endl;
outFile<<endl;
outFile<<endl;
outFile<<endl;
outFile<<endl;
outFile<<endl;
outFile<<"Huntsville Utilities"<<right<<setw(40)<<"Telephone Numbers"<<endl;
outFile<<"TO REPORT AN OUTAGE-(256)53-LIGHT 535-
4448"<<right<<setw(25)<<"Huntsville City Garbage-(256) 883-3964"<<endl;
outFile<<"FOR ALL OTHER CUSTOMER INQUIRIES (256) 535-1200/Toll Free 866-478-
8845"<<" Huntsville City Sewer-(256) 883-3719"<<endl;
outFile<<"Have account number and pin number available"<<right<<setw(25)<<"Madison
County Garbage-(256) 532-3718"<<endl;
outFile<<"PAYMENT BY CREDIT CARD/SPEEDPAY 1-877-429-
4131"<<right<<setw(25)<<"Madison County Water-(256) 746-2888"<<endl;
outFile<<right<<setw(45)<<"City of New Hope-(256) 723-2616"<<endl;
outFile<<"________________________________________________________________________
________"<<endl;
outFile<<endl;
}
return 0;
}