I have tried to develop a code using arrays and void functions to take the current earnings of employees and using it to calculate their future income in ten years. This was performed by a 8% percent increase every year. below i've posted my attempt and for some reason the code will compile successfully however, when trying to run the program there are errors or bugs. If i can get any help it would be greatly appreciated.
Ric712: [code=cpp]#include <iostream>
#include <fstream>
using namespace std;
void input(char name[6][6], double salary[6], double &prog, int &j);
void output(char name[6][6], double salary[6], double prog, int j);
int main()
{
char name[6][6];
double salary[6], prog;
int j;
input(name, salary, prog, j);
output(name, salary, prog, j);
return 0;
}
void input(char name[6][6], double salary[6], double &prog, int &j)
{
double p = 0.0;
ifstream sam;
sam.open("book. dat");
while(!(sam.eof ()))
{
int i(0);
j=j+1;
sam >> name[j] >> salary [j];
for(i=1; i <= 10; i++)
{
double inc = 0.0;
inc = salary[j]*(1.08);
p = inc + p;
}
}
prog=p;
sam.close();
}// end input
void output(char name[6][6], double salary[6], double prog, int j)
{
cout << "People and progressed salaries:\n";
cout << "--------------------------------------------------\n";
for(j=1;j<=6;j+ +)
cout << name[j] << " " << salary [j] << endl;
cout << "\nThe future salary in 10 years is " << prog << endl;
}[/code]
Ric712: [code=cpp]#include <iostream>
#include <fstream>
using namespace std;
void input(char name[6][6], double salary[6], double &prog, int &j);
void output(char name[6][6], double salary[6], double prog, int j);
int main()
{
char name[6][6];
double salary[6], prog;
int j;
input(name, salary, prog, j);
output(name, salary, prog, j);
return 0;
}
void input(char name[6][6], double salary[6], double &prog, int &j)
{
double p = 0.0;
ifstream sam;
sam.open("book. dat");
while(!(sam.eof ()))
{
int i(0);
j=j+1;
sam >> name[j] >> salary [j];
for(i=1; i <= 10; i++)
{
double inc = 0.0;
inc = salary[j]*(1.08);
p = inc + p;
}
}
prog=p;
sam.close();
}// end input
void output(char name[6][6], double salary[6], double prog, int j)
{
cout << "People and progressed salaries:\n";
cout << "--------------------------------------------------\n";
for(j=1;j<=6;j+ +)
cout << name[j] << " " << salary [j] << endl;
cout << "\nThe future salary in 10 years is " << prog << endl;
}[/code]
Comment