Formulas?

I need help writing a formula to solve a simple workplace problem.

The situation is:

"Workers at a particular 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 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."

The 7.6% isn't the issue i'm having trouble figuring out how to get retro pay afterwards, and what is the const modifier and how would I use it in this situation?

Here is what I have so far
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>
#include <fstream>
using namespace std;
#include <string>
int main()
/*******************************************************************************************************************************************
This is a program that shows your salary increase based on the companies 7.6% pay increase and what the company
owes you in back pay from the last 6 months. 
*///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
{
	// I will define my variables here
	int currentSalary, newSalary, retroPay; 

	// Here I will gather the information from the user
	cout << "What is your current Salary?: "; 
	cin >> currentSalary; 

	// Here I will show the equation to calculate retro pay and new salary.


	return 0;
}
const means that the variable can not be modified. In other words your professor wants something like this const float payIncrease = 0.076f;.

Basically salary is how much money you earn in a year. Here is how retroactive salary works.

An old annual salary of $40,000 with a 7.6% increase.
The new annual salary is 1.076 * 40000 = 43040
The amount of retroactive pay = new annual salary / pay periods ( 12 ) - old annual salary / pay periods( 12 ) = 43040 / 12 - 40000 - 12 = 3586.67 - 3333.33 = 253.33 * payments of raise ( 6 ) = 1519.98

Last edited on
Yea sorry I was just about to edit my submission and say I have about everything worked out except the const. Here is what I have right now.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <iostream>
#include <fstream>
using namespace std;
int main()
/*******************************************************************************************************************************************
This is a program that shows your salary increase based on the companies 7.6% pay increase and what the company
owes you in back pay from the last 6 months.
*///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    
{
    // I will define my variables here

    int currentSalary, newSalary, retroPay, monthlySalary;

    // I will now let the user know what the program's intended use is

    cout << "Hello valued employee, this is a company wide message to all our staff letting you know some great news, your getting a raise! ";
    cout << "Starting next week we will be giving you a 7.6% pay increase, and since were half way through the financial year, ";
    cout << "you will be receiving retro pay based on the difference for 6 months. ";
    cout << "You will be receiving your official statement by mail, but if you would like to know the difference we have made a calculator ";
    cout << "to show you, your new pay and bonus, all we need is your current salary.";
    cout << "\n";

    // Here I will gather the information from the user
	cout << "\n"; 
    cout << "What is your current Salary?: ";
    cin >> currentSalary;
    
    //Here I will create my formuals

    newSalary = currentSalary * 1.076;

    monthlySalary = newSalary / 12;

    retroPay = (newSalary - currentSalary) / 2;

    //Now I will display the output to the user

    cout << "\n";
    cout << "Your new yearly salary is: ";
    cout << newSalary;
    cout << "\n";

    cout << "Your new monthly salary is: ";
    cout << monthlySalary;
    cout << "\n";

    cout <<"And the company owes you: ";
    cout << retroPay;
    cout << "\n";


    return 0;
}


So how would I add const to this equation? Since it basically does everything when ran?
Last edited on
const is something you use to declare a value that will never change. It is usually put above main so that the value is global. Also, since you are calculating decimal numbers I would use float or double instead of int.

For instance:

const float retroPercent = .076;

I assume you mean you don't know the math calculation to determine what the total pay should be.

You will want 4 variables. One to hold the current annual salary, one to hold the retro pay due, one to hold the new annual pay, and one to hold the new monthly pay.

So to get the retro pay you would take your annual salary and divide it in half. That will get your math to the point of the 6 month retro. Take that number and multiply it by the .076 increase to get the retro amount due. IOW

(annual salary / 2) * .076 <--- just use your annual salary variable and your const variable in place of annual salary and the .076.

Next you want to find the new annual salary. The math for that is to take your current annual salary multiply it by the const variable, then add it back to current salary. IOW

(current salary * insert const variable name here) + current salary

Next you want to find your new monthly salary. Take the variable that is now holding your new annual salary and divide by 12. IOW

newAnnual / 12

Then output all the information requested.


Finally your need to wrap all your code into a loop that will ask the user if they want to do another one or quit program.

Last edited on
well now i'm getting build errors?
Ok, I switched main to float,
and my variables including the const to float.
now it's working.
What do you mean you switch main to float? Leave main int.

Put above main: const float retroPercent = 1.076

change this line: newSalary = currentSalary * 1.076;

to: newSalary = currentSalary * retroPercent;


That should work to the requirements of the problem.
There is no need to make it a global in this program.
Topic archived. No new replies allowed.