Write a pay-raise program that requests a person's first name, last name, and current annual salary and then displays the person's salary for next year. People earning less than $40,000 will receive a 5% raise, and those earning $40,000 or more will receive a raise of $2,000 plus 2% of the amount over $40,000. Use functions for input and output, and a function to calculate the new salary.
You didn't define language for problem, So i am doing it in C++ programming language
#include <iostream>
#include<string>
using namespace std;
int input(string fname,string lname)
{
cout<<"Enter first name: ";
cin>>fname; // Input first name from user
cout<<"Enter last name: ";
cin>>lname; // Input last name from user
return 0;
}
int calculate( int sal)
{ cout<<"Enter current salary: ";
cin>>sal; // Input current year salary from user
if (sal < 40000)
{
return sal + (sal * 0.05); // if loop return the salary increased by 5%
}
return 2000 + ((0.02 * sal) + sal); // If salary is greater than 40000
// Then increase salary by (2% + cureent salary)
}
int main()
{ string fname, lname;
int salary;
input(fname, lname); // Function calling for input first and last name
int nextsal = calculate(salary); // calling calculate function to calculate next year salary
cout<<"Person's next year salary is: "<<nextsal; // Output of next year salary
return 0;
}
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images