Code:
#include <iostream>
#include <string.h>
using namespace std;
void print_main_Heading(int&, int&);
void print_Column_Heading(int&, int&);
void readtolldetails (int& , int& , string& , string& , string& ,int& , int& );
void calculateToll(int& , char& , int& , float& , float& , float& , float& );
void resetContotals(double&);
void printTotalInvoice (const int& , char& , float& , float& , float& , float& , float& );
const int MAX_LINES =100;
const int MAX_LINE = 100;
const int MAX_SIZE = 20;
double TotalInvoice = 0;
int pageCount = 0;
int lineCount = 0;
bool more= true;
void print_main_Heading(int& pageCount, int& lineCount)
{
pageCount = pageCount +1;
cout<<"Interstate motorway tax invoice"<<endl;
cout<<"cutomer id\tname\adress" ;
lineCount = 2;
}
void printCustomerHeading(int& pageCount, int& lineCount)
{
pageCount = pageCount +1;
cout<<"DATE\t\tTIME\tAMOUNT\n\n";
lineCount = 1;
}
void readtolldetails (int& MAX_LINE, int& MAX_SIZE, string& date, string& time, string& ipString,int& i, int&gate)
{
date [MAX_SIZE];
time [MAX_SIZE];
ipString;
i =0;
do {
cerr<<"proceeding..."<<endl;
getline(cin, ipString);
if(cin.fail()) break;
int position = ipString.find ('/');
date [i] = ipString.substr(0, 10);
time [i] = ipString.substr(11,16-11);
i++;
}
while (i<MAX_SIZE);
for (int j=0; i<j; i++)
cout <<date[j]<<"\t"<<time[j]<<endl;
}
void calculatetoll (string& station, int i, float& a, float& b, float& c, float&d,float& total, double& contotal)
{
a = 0;
b = 0;
c = 0;
d = 0;
int j = 0;
do
{
if (station [j] == "A")
{
a= a + 2.20;
cout<<a;
}
else if(station[j] == " B")
{
b= b + 2.80;
cout<<b;
}
else if(station[j] == "C")
{
c= c + 2.30;
cout<<c;
}
else if(station[j] == "D")
{
d= d + 3.80;
cout<<d;
}
total = a + b+ c + d;
cout<<"TOTAL:" << total <<endl;
cout<<"please make payment as soon as possible."<<endl;
resetContotals(contotal);
}
while(j < i);
}
void resetContotals(double& contotal)
{
contotal = 0;
}
int main ()
{
int currentid;
int previd;
string custid;
string prevcustid;
double contotal;
int pageCount;
int lineCount;
char station;
int i;
float a, b, c, d, total;
string ipstring;
previd =currentid;
prevcustid=custid;
while(more)
{
if (currentid!=previd)
calculateToll (MAX_SIZE, station, i , a , b, c, d);
previd= currentid;
prevcustid= custid;
}
if (lineCount >MAX_LINES)
print_main_Heading(pageCount, lineCount);
print_Column_Heading(pageCount, lineCount);
readtolldetails (MAX_LINE, MAX_SIZE,ipString, i);
calculateToll(MAX_SIZE, station, i, a, b, c, d );
printTotalInvoice (MAX_SIZE, station, a, b, c, d, total);
system("pause");
return 0;
}