Hi,
This is my 1st post, am rather stuck with a problem with my function call program. The program itself shud show 7 Customers and there amount of savings using Intergers and Floats As shown below. The problem is the program itself is only showing 6 Customers. This is racking my brain, can anyone help ?
Code:
/* CH1702.cpp */
/* A program to calculate savings in a building society */
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <math.h>
void main ()
{
/* Description ........
Open input file
Display headings
Initialise total savings and customer number
Read first customer details
WHILE customers to process
Add one to customer number
Evaluate amount of savings
Display customer number and savings
Accumulate total savings
Read next customer details
Display total savings
Close input file
*/
int number_of_years,
customer_number ;
float interest_rate,
initial_investment,
customer_savings,
total_savings ;
void drawaline (float &, float, float, int);
FILE *inputfile = fopen ("CH1702.txt" , "r");
if (inputfile == NULL)
{
printf ("Sorry File Not Found\n");
getch ();
exit (1);
}
printf ("CUSTOMER AMOUNT OF SAVINGS\n");
total_savings = 0;
customer_number = 0;
fscanf (inputfile, "%d" "%f%f\n", &number_of_years, &interest_rate, &initial_investment);
while(feof (inputfile) == 0)
{
++ customer_number;
drawaline (customer_savings, interest_rate, initial_investment, number_of_years);
printf ("%4d" "%14.2f\n", customer_number, customer_savings);
total_savings += customer_savings;
fscanf (inputfile, "%d" "%f%f", &number_of_years, &interest_rate, &initial_investment);
}
printf ("Total %13.2f", total_savings);
fclose (inputfile);
getch () ;
}
/*Function For Customers Savings*/
void drawaline (float & A, float R, float I, int N)
{
/*Description ........
Calculate amount of savings
*/
A = pow (1 + R / 100, N) * I ;
}
getch () ;
Hope i did the tag right by the way as well.
Ne help would be great btw.
Daz