SHARE
SPREAD
HELP

The Tradition of Sharing

Help your friends and juniors by posting answers to the questions that you know. Also post questions that are not available.


To start with, Sr2Jr’s first step is to reduce the expenses related to education. To achieve this goal Sr2Jr organized the textbook’s question and answers. Sr2Jr is community based and need your support to fill the question and answers. The question and answers posted will be available free of cost to all.

 

#
Authors:
Walter Savitch ,julia Lobur
Chapter:
C++ Basics
Exercise:
Programming Projects
Question:3 | ISBN:9780321531346 | Edition: 7

Question

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.

TextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbook

Answer

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.
0 0

Discussions

Post the discussion to improve the above solution.