Well here is my program. I'm new to C++ and new to this forum. Hopefully someone can tell me how to get over this hurdle. I need to use a for loop to change the years to year 1, year 2 etc. My problem is that I need to output the estimated and adjusted salary also for each year. I am stuck! Whenever I run it like this, the years change however it only outputs the estimated and adjusted for year 1. Help??
Code:
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
const double INFLATION_RATE = .0285;
double annual_salary = 0;
double growth_rate = 0;
double yr_1 = 0,
yr_2 = 0,
yr_3 = 0;
double adjusted_yr1 = 0,
adjusted_yr2 = 0,
adjusted_yr3 = 0;
double annual_growth = 0;
double annual_inflation = 0;
double total_estimated = 0;
double total_adjusted = 0;
double growth_percent = 0;
double annual_growthYR1 = 0;
double annual_growthYR2 = 0;
double annual_growthYR3 = 0;
double annual_inflationYR2 = 0;
double annual_inflationYR3 = 0;
double count = 0;
cout << "Enter your annual salary: ";
cin >> annual_salary;
cout << endl;
cout << "Enter the estimated yearly rate of growth for your salary in percent: ";
cin >> growth_percent;
cout << endl;
//ESTIMATED INCOME CALCULATIONS
growth_rate = growth_percent/100;
annual_growthYR1 = annual_salary * growth_rate;
yr_1 = annual_salary + annual_growthYR1;
annual_growthYR2 = yr_1 * growth_rate;
yr_2 = yr_1 + annual_growthYR2;
annual_growthYR3 = yr_2 * growth_rate;
yr_3 = yr_2 + annual_growthYR3;
total_estimated = yr_1 + yr_2 + yr_3;
// ADJUSTED INCOME CALCULATIONS
annual_inflation = annual_salary * INFLATION_RATE;
adjusted_yr1 = yr_1 - annual_inflation;
annual_inflationYR2 = yr_1 * INFLATION_RATE;
adjusted_yr2 = yr_2 - annual_inflationYR2;
annual_inflationYR3 = yr_2 * INFLATION_RATE;
adjusted_yr3 = yr_3 - annual_inflationYR3;
total_adjusted = adjusted_yr1 + adjusted_yr2 + adjusted_yr3;
for (count = 1; count < 4; ++count)
{
//OUTPUT
cout << " The estimated salary for year " << count << " is " << yr_1 << endl;
cout << " The adjusted salary for year " << count << " is " << adjusted_yr1 << endl << endl;
}// END FOR LOOP
cout << " The total estimated salary for all 3 years is " << total_estimated << endl
<< " and the total adjusted salary for all 3 years is " << total_adjusted;
cout << endl << endl;
cout << "***************************************************************************" << endl << endl;
return(0);
}//END MAIN
Comment