summaryrefslogtreecommitdiff
path: root/BlankConsoleLab/BlankConsoleLab.cpp
blob: c5a2a56b4905e8c90f2643dc8465c376886ab1a0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//Lab 3



#include <iostream>
#include <fstream>	// For the files!!!!
#include <iomanip>	// For manipulators & formatting options
using std::cin;
using std::cout;
using std::endl;
using std::setw;
using std::ios;

using std::ifstream;
using std::ofstream;


const int MAX = 100;

int ReadData(ifstream& inFile, int pick[], int drop[], int psgr[], float dist[], float fare[], float toll[], float tfare[]);
void WriteOutputFile(ofstream& outFile, int pick[], int drop[], int psgr[], float dist[], float fare[], float toll[],
	int counter);
void PrintTotalsAndSummary(ofstream& out, int totalRecords);

int main()
{

}

int ReadData(ifstream& inFile, int pick[], int drop[], int psgr[], float dist[], float fare[], float toll[], float tfare[])
{
	int counter = 0;
	inFile >> pick[counter] >> drop[counter] >> psgr[counter] >> dist[counter] >> fare[counter] >> toll[counter];

	while (!inFile.eof())
	{
		tfare[counter] = fare[counter] + toll[counter];

		cout << setiosflags(ios::left) << setw(5)
			<< pick[counter] << resetiosflags(ios::left)
			<< setw(10) << drop[counter] << resetiosflags(ios::left)
			<< setw(12) << psgr[counter] << resetiosflags(ios::left)
			<< setw(14) << dist[counter] << resetiosflags(ios::left)
			<< setw(14) << fare[counter] << resetiosflags(ios::left)
			<< setw(14) << toll[counter] << resetiosflags(ios::left)
			<< setw(14) << tfare[counter] << resetiosflags(ios::left)
			<< endl;
		counter++;
		inFile >> pick[counter] >> drop[counter] >> psgr[counter] >> dist[counter] >> fare[counter] >> toll[counter] >> tfare[counter];
	}

	return counter;
}

void WriteOutputFile(ofstream& outFile, int pick[], int drop[], int psgr[], float dist[], float fare[], float toll[],
	int counter)
{
	outFile << "   Here is the Output File" << endl;
	for (int i = 0; i <= counter - 1; i++)
	{
		outFile << setiosflags(ios::left) << setw(5)
			<< pick[i] << resetiosflags(ios::left)
			<< setw(10) << drop[i] << resetiosflags(ios::left)
			<< setw(12) << psgr[i] << resetiosflags(ios::left)
			<< setw(14) << dist[i] << resetiosflags(ios::left)
			<< setw(14) << fare[i] << resetiosflags(ios::left)
			<< setw(14) << toll[i]
			<< endl;
	}
}

void PrintTotalsAndSummary(ofstream& outFile, int totalRecords)
{
	// To screen
	cout << "\n\n\t** Total Records: " << totalRecords << " **\n"
		<< "\t\t The End \n";

	// To file
	outFile << "\n\n\t** Total Records: " << totalRecords << " **\n"
		<< "\t\t The End \n";
}