Input/Output

So I've been working on an assignment for a class, and I was receiving help from a grad student and he said my program looked good and to turn it in. However, the auto-evaluate program did not work with my code and it would not compile. Anyone have suggestions?
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
int main()
{
 std::string inputFileName;
 std::string outputFileName;
 double interestRate;
 std::cout << "Enter an input filename: ";
 std::cin >> inputFileName;
 std::cout << "Enter an output filename: ";
 std::cin >> outputFileName;
 std::cout << "Enter an interest rate (%): ";
 std::cin >> interestRate;
 std::cout << std::endl;
 std::ifstream ifile = GetInputFile(inputFileName);
 std::ofstream ofile = GetOutputFile(outputFileName);
 std::cout << "Current account status:" << std::endl;
 PrintFileContents(ifile);
 ProcessAccounts(ifile, ofile, interestRate);
 ifile.close();
 ofile.close();
 std::cout << std::endl;
 std::cout << "New account status:" << std::endl;
 ifile = GetInputFile(outputFileName);
 PrintFileContents(ifile);
 ifile.close();
 std::cout << "Press ENTER";
 std::cin.ignore();
 std::cin.get();
 return 0;
}
//[END MAIN]
void ProcessAccounts(std::ifstream &ifile, std::ofstream &ofile, double rate)
void PrintFileContents(std::ifstream &str)
{
 // Print the contents of the file
 // First, print the file headers
 // Then, print each line.
 // Make sure the text is properly formatted
 // Remember the functions available in iomanip?
 // EXAMPLE:
 // Name Savings Credit
 // Bob $23.56 $0.00
 // Joe $43.52 $0.00
 // Sally -$1.58 $0.00
 // Put your code here

	//printing contents of file
	std::string name;
	double savingsbalance;
	double creditbalance; 
	std::cout <<"Name\tSavings\tCredit" << std::endl;
	str >> name >> savingsbalance >> creditbalance;

	while(!str.eof())
	{
		std::cout << std::setprecision(2) << std::fixed << name << "\t$" << savingsbalance <<"\t$"<< creditbalance << std::endl;
		str >> name >> savingsbalance >> creditbalance;
	}
std::ifstream GetInputFile(std::string filename)
{
	// Open the file named filename
	// Make sure it exists
	// Return it as an input file stream

	// Put your code here
	std::ifstream ifile;

	ifile.open(filename); //open file

	if(!ifile.is_open())
	{
		ifile.close(); //determine if file can open
	}
	else;
	{
		std::cout <<"Error. Unable to open file " << std::endl;
	}
	return ifile; //showing error if unable

 // Put your code here
}
std::ofstream GetOutputFile(std::string filename)
{
 // Open the file named filename
 // Make sure it exists
 // Return it as an output file stream
	std::ofstream ofile;

	ofile.open(filename); //open file
//determine if file can open
	if(!ofile.is_open())
	{
		ofile.close();
	}
	else
	{
		std::cout <<"Error. Unable to open file" << std::endl; //error message
	}
	return ofile;
 // Put your code here
}
void SetInputStreamPos(std::ifstream &str, int pos)
{
 // Set the 'g'et cursor to the desired byte in the stream
 // Use the beginning of the file as the reference point

 // Put your code here
	str.clear();
	str.seekg(pos, std::ios::beg);
}
void SetOutputStreamPos(std::ofstream &str, int pos)
{
 // Set the 'p'ut cursor to the desired byte in the stream
 // Use the beginning of the file as the reference point

 // Put your code here
		str.clear();
	str.seekp(pos, std::ios::beg);
}
Did you try to compile it yourself? Because it is not compiling. You need to either move your functions before main() or forward-declare them
Topic archived. No new replies allowed.