Mar 11, 2012 at 3:35am UTC
Here is my code:
using namespace std;
double year1 = 0.0;
double year2 = 0.0;
double year3 = 0.0;
double salary = 0.0;
double raise = 0.0;
double totalSalary = 0.0;
const double rate = .05;
cout << "Enter Annual Salary: $ " ;
cin >> salary;
year1 = salary *(1.+ rate);
year2 = year1 * (1.+rate);
year3 = year2 * (1.+rate);
totalSalary = year1 + year2 + year3;
cout << fixed << setprecision(2);
cout << "After Year 1: $ " << year1 << endl;
cout << "After Year 2: $ " << year2 << endl;
cout << "After Year 3: $ " << year3 << endl;
cout << "Total salary for the three years:$ " << totalSalary << endl;
} //end of main function
My problem it is not staying up on the screen with the option to 'Press any key to continue.'
Would someone please help me with this. I am a beginner.
Mar 11, 2012 at 3:51am UTC
You commented out the call to system()...
Should be just
(or an equivalent to that)
Mar 11, 2012 at 12:54pm UTC
lets do one thing!
Initialise a variable like
now after completing all your programming and other codes, place the following line just before the statement. return 0;
With this statement placed just before the 'return 0' statement, will make the program to wait for another input from the user and thus wait for an "input" and hence the output will stay on the screen until an input is given.
Hope this helps!