PLease can anyone debug my program for me!:
#include <iostream.h>
#include <fstream.h>
#include <string.h>
const int MAX_SIZE = 20;
const int MAX = 10;
typedef char string[MAX_SIZE];
void mortgage(int mort_int[MAX],float mort_float[MAX],string mort_name[MAX]);
void loan(int loan_int[MAX],float loan_float[MAX],string loan_name[MAX]);
void savings(int save_int[MAX],float save_float[MAX],string save_name[MAX]);
void output(int mort_int[MAX],float mort_float[MAX],string mort_name[MAX],
int loan_int[MAX],float loan_float[MAX],string loan_name[MAX],
int save_int[MAX],float save_float[MAX],string save_name[MAX]);
void main()
{
mortgage(int mort_int[MAX],float mort_float[MAX],string mort_name[MAX]);
loan(int loan_int[MAX],float loan_float[MAX],string loan_name[MAX]);
savings(int save_int[MAX],float save_float[MAX],string save_name[MAX]);
output(int mort_int[MAX],string mort_name[MAX],int loan_int[MAX],
string loan_name[MAX],int save_int[MAX],string save_name[MAX]);
}
void mortgage(int mort_int[MAX],float mort_float[MAX],string mort_name[MAX])
{
float mort_ave=0;
float mort_tot = 0;
int counter = 0;
ifstream in_file;
in_file.open ("mort.txt"
cout <<"\n Mortgage info"<<endl<<endl;
int j = 0;
in_file >> mort_name[j]>>mort_int[j]>>mort_float[j];
while (!in_file.eof())
{
cout << mort_name[j]<<" "<< mort_int[j] <<" "<< mort_float[j] <<endl;
j++;
in_file >> mort_name[j] >>mort_int[j]>>mort_float[j];
counter ++;
}
for (j = 0;j < MAX; ++j)
{
mort_tot = mort_tot + mort_float[j];
mort_ave = mort_tot / counter;
}
cout <<"average is "<<mort_ave<<endl;
cout <<"maximum is "<<mort_tot<<endl;
in_file.close();
}
void loan(int loan_int[MAX],float loan_float[MAX],string loan_name[MAX])
{
int k =0;
int counter =0;
float loan_tot;
float loan_ave;
ifstream in_file;
in_file.open ("loan.txt"
cout <<"\n loan info"<<endl<<endl;
in_file >>loan_name[k]>>loan_int[k]>>loan_float[k];
while (!in_file.eof())
{
cout << loan_name[k]<<" "<< loan_int[k] <<" "<< loan_float[k] <<endl;
k++;
counter++;
in_file >> loan_name[k]>>loan_int[k]>>loan_float[k];
}
for (int j = 0;j < MAX; ++j)
{
loan_tot = loan_tot + loan_float[j];
loan_ave = loan_tot / counter;
}
cout <<"average is "<<loan_ave<<endl;
cout <<"maximum is "<<loan_tot<<endl;
in_file.close();
}
void savings(int save_int[MAX],float save_float[MAX],string save_name[MAX])
{
int counter =0;
float save_tot =0;
float save_ave =0;
ifstream in_file;
in_file.open ("save.txt"
cout <<"\n Savings info"<<endl<<endl;
int i = 0;
in_file >> save_name>>save_int>>save_float;
while (!in_file.eof())
{
cout << save_name<<" "<< save_int <<" "<< save_float <<endl;
i++;
counter ++;
in_file >> save_name>>save_int>>save_float;
}
for (int j = 0;j < MAX; ++j)
{
save_tot = save_tot + save_float[j];
save_ave = save_tot / counter;
}
cout <<"average is "<<save_ave<<endl;
cout <<"maximum is "<<save_tot<<endl;
in_file.close();
}
void output(int mort_int[MAX],string mort_name[MAX],int loan_int[MAX],
string loan_name[MAX],int save_int[MAX],string save_name[MAX])
{
ofstream single_out_file;
ofstream joint_out_file;
single_out_file.open("1's.txt"
joint_out_file.open("2's.txt"
for (int j = 0;j < MAX; ++j)
{
if (mort_int[j] == 1)
single_out_file <<"Mortgage "<< mort_name[j] <<" " << mort_int[j] << endl;
if (loan_int[j] == 1)
single_out_file <<"loan " << loan_name[j] <<" " << loan_int[j] <<endl;
if (save_int[j] == 1)
single_out_file <<"savings "<< save_name[j] <<" " << save_int[j] <<endl;
if (mort_int[j] == 2)
joint_out_file <<"Mortgage "<< mort_name[j] <<" " << mort_int[j] <<endl;
if (loan_int[j] == 2)
joint_out_file <<"loan "<< loan_name[j] <<" " << loan_int[j] <<endl;
if (save_int[j] == 2)
joint_out_file <<"savings "<< save_name[j] <<" " << save_int[j] <<endl;
}
}
#include <iostream.h>
#include <fstream.h>
#include <string.h>
const int MAX_SIZE = 20;
const int MAX = 10;
typedef char string[MAX_SIZE];
void mortgage(int mort_int[MAX],float mort_float[MAX],string mort_name[MAX]);
void loan(int loan_int[MAX],float loan_float[MAX],string loan_name[MAX]);
void savings(int save_int[MAX],float save_float[MAX],string save_name[MAX]);
void output(int mort_int[MAX],float mort_float[MAX],string mort_name[MAX],
int loan_int[MAX],float loan_float[MAX],string loan_name[MAX],
int save_int[MAX],float save_float[MAX],string save_name[MAX]);
void main()
{
mortgage(int mort_int[MAX],float mort_float[MAX],string mort_name[MAX]);
loan(int loan_int[MAX],float loan_float[MAX],string loan_name[MAX]);
savings(int save_int[MAX],float save_float[MAX],string save_name[MAX]);
output(int mort_int[MAX],string mort_name[MAX],int loan_int[MAX],
string loan_name[MAX],int save_int[MAX],string save_name[MAX]);
}
void mortgage(int mort_int[MAX],float mort_float[MAX],string mort_name[MAX])
{
float mort_ave=0;
float mort_tot = 0;
int counter = 0;
ifstream in_file;
in_file.open ("mort.txt"
cout <<"\n Mortgage info"<<endl<<endl;
int j = 0;
in_file >> mort_name[j]>>mort_int[j]>>mort_float[j];
while (!in_file.eof())
{
cout << mort_name[j]<<" "<< mort_int[j] <<" "<< mort_float[j] <<endl;
j++;
in_file >> mort_name[j] >>mort_int[j]>>mort_float[j];
counter ++;
}
for (j = 0;j < MAX; ++j)
{
mort_tot = mort_tot + mort_float[j];
mort_ave = mort_tot / counter;
}
cout <<"average is "<<mort_ave<<endl;
cout <<"maximum is "<<mort_tot<<endl;
in_file.close();
}
void loan(int loan_int[MAX],float loan_float[MAX],string loan_name[MAX])
{
int k =0;
int counter =0;
float loan_tot;
float loan_ave;
ifstream in_file;
in_file.open ("loan.txt"
cout <<"\n loan info"<<endl<<endl;
in_file >>loan_name[k]>>loan_int[k]>>loan_float[k];
while (!in_file.eof())
{
cout << loan_name[k]<<" "<< loan_int[k] <<" "<< loan_float[k] <<endl;
k++;
counter++;
in_file >> loan_name[k]>>loan_int[k]>>loan_float[k];
}
for (int j = 0;j < MAX; ++j)
{
loan_tot = loan_tot + loan_float[j];
loan_ave = loan_tot / counter;
}
cout <<"average is "<<loan_ave<<endl;
cout <<"maximum is "<<loan_tot<<endl;
in_file.close();
}
void savings(int save_int[MAX],float save_float[MAX],string save_name[MAX])
{
int counter =0;
float save_tot =0;
float save_ave =0;
ifstream in_file;
in_file.open ("save.txt"
cout <<"\n Savings info"<<endl<<endl;
int i = 0;
in_file >> save_name>>save_int>>save_float;
while (!in_file.eof())
{
cout << save_name<<" "<< save_int <<" "<< save_float <<endl;
i++;
counter ++;
in_file >> save_name>>save_int>>save_float;
}
for (int j = 0;j < MAX; ++j)
{
save_tot = save_tot + save_float[j];
save_ave = save_tot / counter;
}
cout <<"average is "<<save_ave<<endl;
cout <<"maximum is "<<save_tot<<endl;
in_file.close();
}
void output(int mort_int[MAX],string mort_name[MAX],int loan_int[MAX],
string loan_name[MAX],int save_int[MAX],string save_name[MAX])
{
ofstream single_out_file;
ofstream joint_out_file;
single_out_file.open("1's.txt"
joint_out_file.open("2's.txt"
for (int j = 0;j < MAX; ++j)
{
if (mort_int[j] == 1)
single_out_file <<"Mortgage "<< mort_name[j] <<" " << mort_int[j] << endl;
if (loan_int[j] == 1)
single_out_file <<"loan " << loan_name[j] <<" " << loan_int[j] <<endl;
if (save_int[j] == 1)
single_out_file <<"savings "<< save_name[j] <<" " << save_int[j] <<endl;
if (mort_int[j] == 2)
joint_out_file <<"Mortgage "<< mort_name[j] <<" " << mort_int[j] <<endl;
if (loan_int[j] == 2)
joint_out_file <<"loan "<< loan_name[j] <<" " << loan_int[j] <<endl;
if (save_int[j] == 2)
joint_out_file <<"savings "<< save_name[j] <<" " << save_int[j] <<endl;
}
}