Workers at a particular company have won a 7.6% pay increase retroactive for six months. Write a program that takes an employee’s previous annual salary as input, and outputs the amount of retroactive pay due the employee, the new annual salary, and the new monthly salary. Use a variable declaration with the modifier const to express the pay increase. Your program should allow the calculation to be repeated as often as the user wishes.
Program Code:
//Header file
#include <iostream>
using namespace std;
int main()
{
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
double previous_annual_salary;
//Prompt the message
cout<<"Congratulations! Workers at your company
have won a 7.6% pay \n"
<<"increase retroactive for six months.";
cout<<"Please enter your previous annual salary: $";
cin>>previous_annual_salary;
cout<<previous_annual_salary<<endl;
double previous_mo_salary = previous_annual_salary/12.0;
double previous_6mo_salary = previous_mo_salary*6.0;
double new_6mo_salary = previous_6mo_salary*1.076;
double retroactive_pay_due =
new_6mo_salary - previous_6mo_salary;
double new_annual_salary = new_6mo_salary*2.0;
double new_monthly_salary = new_6mo_salary/6.0;
//Display output
cout<<"Congratulations! Your retroactive pay is $"
<<retroactive_pay_due<<"."<<endl
<< "Your new annual salary is $"
<<new_annual_salary<<"."<<endl
<<"Your new monthly salary is $"
<<new_monthly_salary<<"."<<endl;
return 0;
}
Output:
Congratulations! Workers at your company have won a 7.6% pay
increase retroactive for six months.Please enter your previous annual salary: $1
00
100.00
Congratulations! Your retroactive pay is $3.80.
Your new annual salary is $107.60.
Your new monthly salary is $8.97.