I have come along way with this project. Here is my latest code. As of now, it is fully functional by pulling the first 3 values from my data file. I need the program to pull out all values from the data file in sets of 3. How would I make the program to continue to pull out the next three values, and the next, until no more values remain in the data file? Thanks alot.
CODE
#include <stdio.h>
#include <math.h>
void calc();
main()
{
printf("\n\nThis program is the work of Ben Hogan, I.D. #211");
calc();
}
/******************************************************/
void calc()
{
double p , n , apr , x , ann , mon;
FILE *infile;
infile = fopen("program_4.dat" , "r");
fscanf( infile , "%lf %lf %lf" , &p , &n , &mon );
apr = 0.;
ann = 0.;
while (ann <= mon)
{
apr = apr + .02;
x = apr / 1200.;
ann = p * x * (pow((1. + x) , n)) / (pow((1. + x) , n) - 1.);
}
printf("\n\nLoan Amount Months Payment Amount Est. Apr(%)\n");
printf("%8g%12g%14g%18g\n\n", p , n , mon , apr);
system("pause");
}
I have attached the data file.