can you check my programming please ntro to programming Modular programming Anon
ID: 3642202 • Letter: C
Question
can you check my programming pleasentro to programming Modular programming
Anonymous asked
3. The trustees of a small college are considering voting a pay raise for
their 12 faculty members. They want to grant a 2.5-percent pay raise;
however, before doing so, they want to know how much this will cost.
Write a program that will print the pay raise for each faculty member
and the total amount of the raises. Also, print the total faculty payroll
before and after the raise. Test your function for the salaries:
$52,500 $64,029.50 $56,000 $53,250
$65,500 $42,800 $45,000.50 $68,900
$53,780 $77,300 $84,120.25 $64,100
4. Redo Programming Project 3 assuming that faculty members earning
less than $50,000 receive a 3-percent raise, those earning more than
$70,000 receive a 3.5-percent raise, and all others receive a 2.5-percent
raise. For each faculty member, print the raise percentage as well as the
amount.
files name is "Faculty data.txt " that include all salaries and last -1
thanks
// C. Patel
// Page 379, prob. 3 and 4
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;
// Function prototypes
void salaryreport1 (double&, double&, double& );
void salaryreport2 (double&, double&, double& );
void main()
{
ifstream inF; double npay, perc, pay, raise, Tpay, tnpay, traise; int n;
inF.open("faculty data.txt");
cout << fixed << setprecision(2);
cout << "Salary Raise Report 1" << endl;
salaryreport1 (pay,raise,npay);
{
//cout << "Salary Raise Report 1" << endl;
cout << " No. Salary Rate Raise New Salary" << endl;
cout << "_______________________________________________" << endl;
n = 1; Tpay = 0; tnpay = 0; traise = 0;
if (inF)
{
while (n!=13)
{
//inF >> pay; //read Current Salary from txt file
//Tpay += pay; //Calculate Total Pay
//raise = pay *.025; //Calculate Raise
//traise += raise; //Calculate total raise
//npay = pay + raise; //Cal new salary
//tnpay += npay; //Cal Total of new salaries
salaryreport1 (pay,raise,npay);
cout << " " << setw(2) << n << " " << pay << " 2.5 " << raise << " " << npay << endl;
n++;
}
}
}
salaryreport2 (pay,raise,npay);
{
//cout << "Salary Raise Report 2" << endl;
cout << " No. Salary Rate Raise New Salary" << endl;
cout << "_______________________________________________" << endl;
n = 1; Tpay = 0; tnpay = 0; traise = 0;
if (inF)
{
while (n!=13)
{
salaryreport2 (pay,raise,npay);
cout << " " << setw(2) << n << " " << pay << " 2.5 " << raise << " " << npay << endl;
n++;
}
}
}
}
/*else
{
cout << "No File" << endl;
}
cout << endl << "Totals " << Tpay << " " << traise << " " << tnpay << endl;
inF.close();
*/
// Function definitions
void salaryreport1 (double& pay, double& raise, double& npay);
{
inF >> pay; //read Current Salary from txt file
Tpay += pay; //Calculate Total Pay
raise = pay *.025; //Calculate Raise
traise += raise; //Calculate total raise
npay = pay + raise; //Cal new salary
tnpay += npay; //Cal Total of new salaries
return 0;
}
void salaryreport2 (double&,double&, double&);
{
inF >> pay; //read Current Salary from txt file
Tpay += pay; //Calculate Total Pay
if (pay <= 50000)
{
raise = pay * 0.03;
}
else if (pay >= 70000)
{
raise = pay * 0.035;
}
else if ( pay >= 50000 || pay <= 70000)
{
raise = pay * .025;
}
traise += raise; //Calculate total raise
npay = pay + raise; //Cal new salary
tnpay += npay; //Cal Total of new
}
Explanation / Answer
please rate - thanks
you have a few errors which I've corrected
in addition this should be 2 distinct programs
program 1
// C. Patel
// Page 379, prob. 3
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;
// Function prototypes
void salaryreport1 (double,double&, double&, double& );
int main()
{
ifstream inF;
double npay, perc, pay, raise, Tpay, tnpay, traise;
int n;
inF.open("faculty data.txt");
cout << fixed << setprecision(2);
cout << "Salary Raise Report 1" << endl;
{
//cout << "Salary Raise Report 1" << endl;
cout << " No. Salary Rate Raise New Salary" << endl;
cout << "_______________________________________________" << endl;
n = 1; Tpay = 0; tnpay = 0; traise = 0;
inF >> pay; //read Current Salary from txt file
while (pay!=-1)
{
//inF >> pay; //read Current Salary from txt file
//Tpay += pay; //Calculate Total Pay
//raise = pay *.025; //Calculate Raise
//traise += raise; //Calculate total raise
//npay = pay + raise; //Cal new salary
//tnpay += npay; //Cal Total of new salaries
salaryreport1 (pay,tnpay,raise,npay);
cout << " " << setw(2) << n << " " << pay << " 2.5 " << raise << " " << npay << endl;
n++;
inF >> pay; //read Current Salary from txt file
}
}
cout<<" Total Pay Before Raises: "<<tnpay<<endl;
cout<<"Total Pay After Raises: "<<npay<<endl;
system("pause");
}
// Function definitions
void salaryreport1 (double pay,double& Tpay, double& traise, double& tnpay)
{double raise,npay;
Tpay += pay; //Calculate Total Pay
raise = pay *.025; //Calculate Raise
traise += raise; //Calculate total raise
npay = pay + raise; //Cal new salary
tnpay += npay; //Cal Total of new salaries
}
----------------------------
program 2
// C. Patel
// Page 379, prob. 4
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;
// Function prototypes
void salaryreport2 (double,double&, double&, double&, double& );
int main()
{
ifstream inF;
double npay, perc, pay, raise, Tpay, tnpay, traise,rate;
int n;
inF.open("faculty data.txt");
cout << fixed << setprecision(2);
cout << "Salary Raise Report 1" << endl;
{
//cout << "Salary Raise Report 1" << endl;
cout << " No. Salary Rate Raise New Salary" << endl;
cout << "_______________________________________________" << endl;
n = 1; Tpay = 0; tnpay = 0; traise = 0;
inF >> pay; //read Current Salary from txt file
while (pay!=-1)
{
//inF >> pay; //read Current Salary from txt file
//Tpay += pay; //Calculate Total Pay
//raise = pay *.025; //Calculate Raise
//traise += raise; //Calculate total raise
//npay = pay + raise; //Cal new salary
//tnpay += npay; //Cal Total of new salaries
salaryreport2(pay,tnpay,raise,npay,rate);
cout << " " << setw(2) << n << " " << pay <<" "<< rate*100. <<" "<< raise << " " << npay << endl;
n++;
inF >> pay; //read Current Salary from txt file
}
}
cout<<" Total Pay Before Raises: "<<tnpay<<endl;
cout<<"Total Pay After Raises: "<<npay<<endl;
system("pause");
}
void salaryreport2 (double pay,double& Tpay, double& traise, double& tnpay,double& rate)
{double raise,npay;
Tpay += pay; //Calculate Total Pay
if (pay <50000) //< not <=
{
rate=0.03;
}
else if (pay > 70000) //> not >=
{
rate=0.035;
}
else if ( pay >= 50000 || pay <= 70000)
{
rate=.025;
}
raise = pay * rate;
traise += raise; //Calculate total raise
npay = pay + raise; //Cal new salary
tnpay += npay; //Cal Total of new
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.