You need a program to maintain information about pay raises for employees. Each
ID: 3675698 • Letter: Y
Question
You need a program to maintain information about pay raises for employees.
Each employee’s data include their name, their department, their current yearly income, and their raise percentage, assume that the following data is to be used:
Name
Department
Current Yearly Income
Raise percentage
Trump,Hillary
Sales
$65111.24
6.5%
Rubio,jeb
Marketing
$88224.13
4.4%
Sanders,Rand
Sales
$77124.55
7.5%
Huchkabee,carly
Sales
$68642.44
5.5%
Paul,Bernie
Marketing
$95111.88
3.8%
Write a C program which uses the following function and parameter passing for an array of structures for the 5 employees.
Allow the user to enter the data for each employee .for each employees, calculator the raise Amount and the new pay Amount. the formulas to use are :
Raise Amount = Current Yearly Income * Raise Percentage /100
New Pay Amount = Current Yearly Income + Raise Amount
Place the calculated values into the array of structures.
B .sort the array of structures on name and print the array after sort is completed.
C .Calculate and point the total of the current yearly incomes, the total of the raise amount, and the Total of the new pay amount for the five employees.
D .Save the array of structures to a text file.
E .Retrieve and print the text file.
F .Save the array of structures to a binary file.
G .Retrieve and print the binary file.
Your program output should include the following: all the employee data printed after being sorted by name, the total of the current yearly incomes, the total of the raise amounts, and total of the new pay amounts for the five employees, the employee data should be printed again after the text file has been saved and retrieved, and the employee data should be printed one last time after binary file has been saved and retrieved.
Name
Department
Current Yearly Income
Raise percentage
Trump,Hillary
Sales
$65111.24
6.5%
Rubio,jeb
Marketing
$88224.13
4.4%
Sanders,Rand
Sales
$77124.55
7.5%
Huchkabee,carly
Sales
$68642.44
5.5%
Paul,Bernie
Marketing
$95111.88
3.8%
Explanation / Answer
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
void main() {
char name[20],
dept[20];
float yrIncome,
raisePercent,
raiseAmt,
newPayAmt,
totalYrIncomes = 0,
totalRaiseAmt = 0,
totalNewPayAmt = 0;
// Initial employee data will be entered here
printf("Please enter employee name: ");
gets(name);
printf("Please enter employee's department: ");
gets(dept);
printf("Please enter employee's income: ");
scanf("%f", &yrIncome);
fflush(stdin);
if ( yrIncome <= 70000 )
raisePercent = 8.5;
else
if ( yrIncome <= 80000 )
raisePercent = 7.2;
else
if ( yrIncome <= 90000 )
raisePercent = 5.9;
else
raisePercent = 5.1;
raiseAmt = (yrIncome * raisePercent) / 100;
newPayAmt = yrIncome + raiseAmt;
totalYrIncomes += yrIncome;
totalRaiseAmt += raiseAmt;
totalNewPayAmt += newPayAmt;
printf("All data entered is as follows: Name: %s Dept: %s Income: $%0.2f Percent Raise: %0.1f Raise Amount: $%0.2f New Income: $%0.2f ", name, dept, yrIncome, raisePercent, raiseAmt, newPayAmt);
// Round 2 of entering employee data
fflush(stdin);
printf("Please enter employee name: ");
gets(name);
printf("Please enter employee's department: ");
gets(dept);
printf("Please enter employee's income: ");
scanf("%f", &yrIncome);
fflush(stdin);
if ( yrIncome <= 70000 )
raisePercent = 8.5;
else
if ( yrIncome <= 80000 )
raisePercent = 7.2;
else
if ( yrIncome <= 90000 )
raisePercent = 5.9;
else
raisePercent = 5.1;
raiseAmt = (yrIncome * raisePercent) / 100;
newPayAmt = yrIncome + raiseAmt;
printf("All data entered is as follows: Name: %s Dept: %s Income: $%0.2f Percent Raise: %0.1f Raise Amount: $%0.2f New Income: $%0.2f ", name, dept, yrIncome, raisePercent, raiseAmt, newPayAmt);
totalYrIncomes += yrIncome;
totalRaiseAmt += raiseAmt;
totalNewPayAmt += newPayAmt;
// Round 3 of entering employee data
fflush(stdin);
printf("Please enter employee name: ");
gets(name);
printf("Please enter employee's department: ");
gets(dept);
printf("Please enter employee's income: ");
scanf("%f", &yrIncome);
fflush(stdin);
if ( yrIncome <= 70000 )
raisePercent = 8.5;
else
if ( yrIncome <= 80000 )
raisePercent = 7.2;
else
if ( yrIncome <= 90000 )
raisePercent = 5.9;
else
raisePercent = 5.1;
raiseAmt = (yrIncome * raisePercent) / 100;
newPayAmt = yrIncome + raiseAmt;
printf("All data entered is as follows: Name: %s Dept: %s Income: $%0.2f Percent Raise: %0.1f Raise Amount: $%0.2f New Income: $%0.2f ", name, dept, yrIncome, raisePercent, raiseAmt, newPayAmt);
totalYrIncomes += yrIncome;
totalRaiseAmt += raiseAmt;
totalNewPayAmt += newPayAmt;
// Round 4 of entering employee data
fflush(stdin);
printf("Please enter employee name: ");
gets(name);
printf("Please enter employee's department: ");
gets(dept);
printf("Please enter employee's income: ");
scanf("%f", &yrIncome);
fflush(stdin);
if ( yrIncome <= 70000 )
raisePercent = 8.5;
else
if ( yrIncome <= 80000 )
raisePercent = 7.2;
else
if ( yrIncome <= 90000 )
raisePercent = 5.9;
else
raisePercent = 5.1;
raiseAmt = (yrIncome * raisePercent) / 100;
newPayAmt = yrIncome + raiseAmt;
printf("All data entered is as follows: Name: %s Dept: %s Income: $%0.2f Percent Raise: %0.1f Raise Amount: $%0.2f New Income: $%0.2f ", name, dept, yrIncome, raisePercent, raiseAmt, newPayAmt);
totalYrIncomes += yrIncome;
totalRaiseAmt += raiseAmt;
totalNewPayAmt += newPayAmt;
// Round 5 of entering employee data
fflush(stdin);
printf("Please enter employee name: ");
gets(name);
printf("Please enter employee's department: ");
gets(dept);
printf("Please enter employee's income: ");
scanf("%f", &yrIncome);
fflush(stdin);
if ( yrIncome <= 70000 )
raisePercent = 8.5;
else
if ( yrIncome <= 80000 )
raisePercent = 7.2;
else
if ( yrIncome <= 90000 )
raisePercent = 5.9;
else
raisePercent = 5.1;
raiseAmt = (yrIncome * raisePercent) / 100;
newPayAmt = yrIncome + raiseAmt;
printf("All data entered is as follows: Name: %s Dept: %s Income: $%0.2f Percent Raise: %0.1f Raise Amount: $%0.2f New Income: $%0.2f ", name, dept, yrIncome, raisePercent, raiseAmt, newPayAmt);
totalYrIncomes += yrIncome;
totalRaiseAmt += raiseAmt;
totalNewPayAmt += newPayAmt;
// Yearly incomes to be accumulated here and printed to screen
fflush(stdin);
printf(" Total yearly incomes before raises: $%0.2f ", totalYrIncomes);
printf("Total raise amounts: $%0.2f ", totalRaiseAmt);
printf("Total new yearly incomes after raises: $%0.2f ", totalNewPayAmt);
system("PAUSE");
}
Sample output
Please enter employee name:
Hillary Trump
Please enter employee's department:
Sales
Please enter employee's income:
65111.24
All data entered is as follows:
Name: Hillary Trump
Dept: Sales
Income: $65111.24
Percent Raise: 8.5
Raise Amount: $5534.46
New Income: $70645.70
Please enter employee name:
Jeb Rubio
Please enter employee's department:
Marketing
Please enter employee's income:
88224.13
All data entered is as follows:
Name: Jeb Rubio
Dept: Marketing
Income: $88224.13
Percent Raise: 5.9
Raise Amount: $5205.22
New Income: $93429.36
Please enter employee name:
Rand Sanders
Please enter employee's department:
Sales
Please enter employee's income:
77124.55
All data entered is as follows:
Name: Rand Sanders
Dept: Sales
Income: $77124.55
Percent Raise: 7.2
Raise Amount: $5552.97
New Income: $82677.52
Please enter employee name:
Carly Huckabee
Please enter employee's department:
Sales
Please enter employee's income:
68642.44
All data entered is as follows:
Name: Carly Huckabee
Dept: Sales
Income: $68642.44
Percent Raise: 8.5
Raise Amount: $5834.61
New Income: $74477.05
Please enter employee name:
Bernie Paul
Please enter employee's department:
Marketing
Please enter employee's income:
95111.88
All data entered is as follows:
Name: Bernie Paul
Dept: Marketing
Income: $95111.88
Percent Raise: 5.1
Raise Amount: $4850.71
New Income: $99962.59
Total yearly incomes before raises: $394214.25
Total raise amounts: $26977.96
Total new yearly incomes after raises: $421192.22
Press any key to continue . . .
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.