Mar 11, 2012 at 3:35am UTC
Here is my code:
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
//declare variables
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;
//Enter Salary
cout << "Enter Annual Salary: $ " ;
cin >> salary;
// Calculation
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;
//system("pause");
return 0;
} //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()...
//system("pause");
Should be just
system("pause" );
(or an equivalent to that)
Mar 11, 2012 at 12:54pm UTC
lets do one thing!
Initialise a variable like
int waiter;
now after completing all your programming and other codes, place the following line just before the return 0;
statement.
cin>>waiter;
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!