Line 81: My compiler generates an error because inputData does not return a value. Line 39 does not use the return value, so you might as well make this a void function.
I ran your program, and received reasonable results.
Enter the credit card balance: $
1000
Enter the interest rate on the credit card (compounded monthly) :
1
Enter the desired monthly payment : $
100
Balance=1000.00
Interest rate: 0.01
Interest per month: 10.00
Press any key to continue . . .
ofstream ofs ("lab6.txt");
ofs << all the variables I want in << endl;
ofs.close();
The program had errors.
I edited the code to reflect my changes.
Is it because of my placement, or the syntax?
The errors came out:
In function 'int main()':
87:5: error: 'in' was not declared in this scope
88:5: error: 'ofs' was not declared in this scope
In function 'void printResults(int&, double&, double&, double&, double&)':
115:5: error: 'ofs' was not declared in this scope
In function 'double calculate(double&, double&, double&, double&, double&, double&, int&)':
176:1: warning: no return statement in function returning non-void [-Wreturn-type]
Line 87, you are closing a non-declared object in.close();
Line 88, you opened a file object at line 66, calling it out. Why are you using ofs.close();? I think you meant out.close();.
Line 115, where did you declare your ofs object? Not in the function, that's for sure.
You declared your calculate function to return a double, but you don't return anything. You pass references into the function so any change made to the variables get returned when the function exits. Use the void return type.
The entire code works. It grab the data from the source file, then output it into another file.
But,
I noticed the following feedbacks:
What does the below mean?
The functions: printHeader(), printResults() and calculate() must be called from main().
Since output functions do not change values of what is being printed out, none of the parameters for printHeader() or printResults() should be reference variables with the exception of the reference to the file.
What is generating this printHeader(), printResults() and calculate() must be called from main(). message? Your compiler? When you run the program? UM-possible to say what the problem is without telling us where the error/warning is from. :)