In: Computer Science
this is c++ basics pleases.
Workers at a company have won a 7.6 % pay increase retroactive for 6 months. Write a program that takes an employee's previous annual salary as input, and output 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.
You do not need to do this last part at this time:
Your program should allow the calculation to be repeated as often as the user wishes.
I do expect to see correct coding standards:
1) Constant declarations use all capital letters.
2) All constant and variable names should be meaningful and add to the understand-ability of the program
3) We should format the output numbers to look like american currency ( dollars, decimal point and two decimal digits ( the cents). 123.45 or 256.00. Not 332.2
//C++ program
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
const double INCREASED_PAY_RATE = 7.6;
const int MONTH=6;
double currentAnnualSalary;
double currentMonthlySalary;
cout<<"Enter current Annual salary : ";
cin>>currentAnnualSalary;
currentMonthlySalary=currentAnnualSalary/12;
for(int month=1;month<=MONTH;month++){
currentMonthlySalary =
currentMonthlySalary*(1+INCREASED_PAY_RATE/(12*100));
currentAnnualSalary =
currentMonthlySalary*12;
cout<<"Month :
"<<month<<"\n Monthly salary :
$"<<setprecision(2)<<fixed<<currentMonthlySalary;
cout<<"\n Annual salary :
$"<<setprecision(2)<<fixed<<currentAnnualSalary<<"\n\n";
}
return 0;
}
//sample output