Dec 20, 2017 at 4:57pm UTC
I would truly appreciate some help on this.
//displays the value of Khaild raise
//at the end of each of three years, using
//increase rates of 3%, 4%, 5% and 6%
//Created/revised by <name> on <date>
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
double currentSalary = 0.0;
double raise = 0.0;
double newSalary = 0.0;
cout << " Enter current Salary: ";
cin >> currentSalary;
cout << endl << fixed << setprecision(0);
for (double rate = 0.03; rate < 0.06; rate += 0.03)
{
cout << "Enter raise percent: " << rate * 100 << "%" << endl;
cin >> raise;
newSalary = currentSalary * rate;
for (int year = 1; year < 6; year += 1)
{
raise = currentSalary * rate;
newSalary += raise;
cout << year << " $" << newSalary << endl;
} //end for
cout << endl;
} //end for
return 0;
} //end of main function
Dec 20, 2017 at 5:10pm UTC
I have made 6 to reflect a 4
for (int year = 1; year < 4; year += 1)
{
raise = currentSalary * rate;
newSalary += raise;
cout << year << " $" << newSalary << endl;
} //end for
Dec 20, 2017 at 7:31pm UTC
The program should calculate and display the amount of Khalid 's annual raise for the next three years using rates of 3%, 4%, 5% and 6%. The program should end when kahlid enters a sentinel value as the salary.
Use 30000 and 50000 for salaries during desk checks.
Dec 20, 2017 at 7:39pm UTC
is it cumulative?
should it be
currentsalary *= rate+1.0?
also the loop over rate seems odd (why increment by 3%?)
Dec 20, 2017 at 7:40pm UTC
I have modified it to this:
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
double currentSalary = 0.0;
double raise = 0.0;
double newSalary = 0.0;
cout << " Enter current Salary: ";
cin >> currentSalary;
cout << endl << fixed<< setprecision(0);
for (double rate = 0.03; rate < 0.07; rate += 0.01)
{
cout << "Enter raise percent: " << rate * 100 << "%" << endl;
cin >> raise;
for (int year = 1; year < 4; year += 1)
{
raise = currentSalary * rate;
newSalary += raise;
cout << year << " $" << newSalary << endl;
} //end for
cout << endl;
} //end for
return 0;
} //end of main function
Dec 20, 2017 at 8:18pm UTC
I fixed it myself thanks.
Final program
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
//declare variables
double currentSalary = 0.0;
double raise = 0.0;
double newSalary = 0.0;
//enter input items
cout << " Enter current Salary: ";
cin >> currentSalary;
cout << endl << fixed<< setprecision(0);
//calculate
for (double rate = 0.03; rate < 0.07; rate += 0.01)
{
cout << "Enter raise percent: " << rate * 100 << "%" << endl;
cin >> raise;
newSalary = currentSalary;
for (int year = 1; year < 4; year += 1)
{
raise = currentSalary * rate;
newSalary += raise;
cout << year << " $" << newSalary << endl;
} //end for
cout << endl;
} //end for
return 0;
} //end of main function