The "Freeola Customer Forum" forum, which includes Retro Game Reviews, has been archived and is now read-only. You cannot post here or create a new thread or review on this forum.
Would you like to process a payroll record. y/n?
Please enter employee ID:123
Please enter employee Name:John Doe
Please enter employee Hours:40
Please enter employee Wage:$10.00
Would youlike to process another payroll. y/n?
Please enter employee ID:124
Please enter employee Name:Jane Smith
Please enter employee Hours:45
Please enter employee Wage:$20.00
Would you like to process another payroll record. y/n?
ID Name HRS Wage Gross SOCSEC STATE FED NET
123 Doe, John 40 10.00 400.00 25.20 14.00 68.00 292.80
124 Smith, Jane 45 20.00 950.00 59.85 33.25 161.50 695.40
End of program.
Press any key to continue
Note: All of the answers after the : of each statement is manually typed in when running the program.
This is the pseudocode that was given to me to use for this project.
const double socSecRate = 0.063;
const double stateRate = 0.035;
const double federalRate = 0.17;
const int maxsize = 10;
int arrays empID, empHours;
double array empWage;
string array empName;
all of size max as well as integer i for the array index and a character response. Initialize all values o numeric arrays to zero and string array to "default".
IF ANYONE CAN WRITE THIS PLEASE EMAIL IT TO ME BY THURSDAY AT 10:00am.
I know I am asking all lot but this is a very important project it determines wether I fiish my degree or not!!!!!
Thank you to whoever helps out at all.
[email protected]
:P
> Heh i might try learning C++
Shouldn't you try learning some English first Sniper?
;-)
#include
//-----------------------------
//Calculate number of characters in an integer
int numberOfChars(int input) {
int temp = 0;
while (pow(10,temp) < input) {
temp++;
}
return temp;
}
//-----------------------------
//Calculate number of characters in an array of chars
int numberOfChars(char input[20]) {
for (int x = 0; x < 20; x++) {
if (input[x] == '\n')
return x;
}
return 0;
}
//-----------------------------
//Calculate the number of characters in a double (max two decimal places)
int numberOfChars(double input) {
int temp = 0;
while (pow(10,temp) < input) {
temp++;
}
if (abs(input) == input) {
//input did not have any decimal places
return temp;
}
if (abs(input*10) == (input*10)) {
//input had one decimal place
return temp + 2;
}
return temp + 3;
}
void main() {
//constant declarations
const double socSecRate = 0.063;
const double stateRate = 0.035;
const double federalRate = 0.17;
const int maxsize = 10;
//maxsizes control how wide the columns are
const int IDmaxsize = 4;
const int Namemaxize = 20;
const int Hoursmaxsize = 5;
const int Wagemaxsize = 5;
const int Grossmaxsize = 6;
const int Socsecmaxsize = 6;
const int Statemaxsize = 5;
const int Fedmaxsize = 5;
const int Netmaxsize = 6;
//variable declarations
int empID[maxsize];
int empHours[maxsize];
double empWage[maxsize];
char empName[20][maxsize];
char tempName[20];
char processAnother = 'y';
int numberOfEmployees = 0;
//-----------------------------
//INPUT SECTION
//-----------------------------
while (processAnother == 'y' && numberOfEmployees <= maxsize) {
for(int a = 0; a < 20; a++) {
tempName[a] = '\n';
}
//get EmployeeID
cout << "Please enter employee ID: ";
cin >> empID[numberOfEmployees];
//get Employee Name into temporary variable, read it into permanent
cin.ignore();
cout << "Please enter employee name: ";
cin.getline(tempName, 20);
for(int x = 0; x < 20; x++) {
empName[x][numberOfEmployees] = tempName[x];
}
//get Employee Hours
cout << "Please enter employee hours: ";
cin >> empHours[numberOfEmployees];
//get Employee Wage
cout << "Please enter employee wage: ";
cin >> empWage[numberOfEmployees];
//get another Employee?
if (numberOfEmployees < maxsize) {
cout << "Would you like to process another payroll. y/n?";
cin >> processAnother;
numberOfEmployees++;
}
else
processAnother = 'n';
}
//-----------------------------
//OUTPUT SECTION
//-----------------------------
bool endlinereached = false;
//print column headings at top
cout << "ID |Name |Hours|Wage |Gross |SocSec|State|Fed |Net\n";
//for each employee...
for (int i = 0; i < numberOfEmployees; i++) {
//print EmployeeID, then enough space to put the cursor in line with the next column
cout << empID[i];
for (int j = 0; j <= IDmaxsize - numberOfChars(empID[i]); j++) {
cout << ' ';
}
//print Employee Name, then enough space to put it in line with the next column
endlinereached = false;
for (int k = 0; k < 20; k++) {
if (empName[k][i] == '\n') {
endlinereached = true;
}
if (endlinereached) {
cout << ' ';
}
else {
cout << empName[k][i];
}
}
cout << ' ';
//print Employee Hours, then enough space to put it in line with the next column
cout << empHours[i];
for (j = 0; j <= Hoursmaxsize - numberOfChars(empHours[i]); j++) {
cout << ' ';
}
//print Employee Wage, then enough space to put it in line with the next column
cout << empWage[i];
for (j = 0; j <= Hoursmaxsize - numberOfChars(empWage[i]); j++) {
cout << ' ';
}
//calculate/print Gross pay, then enough space to put it in line with the next column. Cut off value to two decimal places
cout << (double)abs(empHours[i] * empWage[i] * 100) / 100;
for (j = 0; j <= Grossmaxsize - numberOfChars((double)abs(empHours[i] * empWage[i] * 100) / 100); j++) {
cout << ' ';
}
//calculate/print Social Security, then enough space to put it in line with the next column. Cut off value to two decimal places
cout << (double)abs(empHours[i] * empWage[i] * socSecRate * 100) / 100;
for (j = 0; j <= Socsecmaxsize - numberOfChars((double)abs(empHours[i] * empWage[i] * socSecRate * 100) / 100); j++) {
cout << ' ';
}
//calculate/print State rate, then enough space to put it in line with the next column. Cut off value to two decimal places
cout << (double)abs(empHours[i] * empWage[i] * stateRate * 100) / 100;
for (j = 0; j <= Statemaxsize - numberOfChars((double)abs(empHours[i] * empWage[i] * stateRate * 100) / 100); j++) {
cout << ' ';
}
//calculate/print Federal rate, then enough space to put it in line with the next column. Cut off value to two decimal places
cout << (double)abs(empHours[i] * empWage[i] * federalRate * 100) / 100;
for (j = 0; j <= Fedmaxsize - numberOfChars((double)abs(empHours[i] * empWage[i] * federalRate * 100) / 100); j++) {
cout << ' ';
}
//calculate/print Net pay, then end of line. Cut off value to two decimal places
cout << (double)abs(empHours[i] * empWage[i] * (1 - federalRate - stateRate - socSecRate) * 100) / 100;
for (j = 0; j <= Netmaxsize - numberOfChars((double)abs(empHours[i] * empWage[i] * (1 - federalRate - stateRate - socSecRate) * 100) / 100); j++) {
cout << ' ';
}
cout << endl;
}
}
GADGETS
#include
//-----------------------------
//Calculate number of characters in an integer
int numberOfChars(int input) {
int temp = 0;
while (pow(10,temp) < input) {
temp++;
}
return temp;
}
//-----------------------------
//Calculate number of characters in an array of chars
int numberOfChars(char input[20]) {
for (int x = 0; x < 20; x++) {
if (input[x] == '\n')
return x;
}
return 0;
}
//-----------------------------
//Calculate the number of characters in a double (max two decimal places)
int numberOfChars(double input) {
int temp = 0;
while (pow(10,temp) < input) {
temp++;
}
if (abs(input) == input) {
//input did not have any decimal places
return temp;
}
if (abs(input*10) == (input*10)) {
//input had one decimal place
return temp + 2;
}
return temp + 3;
}
void main() {
//constant declarations
const double socSecRate = 0.063;
const double stateRate = 0.035;
const double federalRate = 0.17;
const int maxsize = 10;
//maxsizes control how wide the columns are
const int IDmaxsize = 4;
const int Namemaxize = 20;
const int Hoursmaxsize = 5;
const int Wagemaxsize = 5;
const int Grossmaxsize = 6;
const int Socsecmaxsize = 6;
const int Statemaxsize = 5;
const int Fedmaxsize = 5;
const int Netmaxsize = 6;
//variable declarations
int empID[maxsize];
int empHours[maxsize];
double empWage[maxsize];
char empName[20][maxsize];
char tempName[20];
char processAnother = 'y';
int numberOfEmployees = 0;
//-----------------------------
//INPUT SECTION
//-----------------------------
while (processAnother == 'y' && numberOfEmployees <= maxsize) {
for(int a = 0; a < 20; a++) {
tempName[a] = '\n';
}
//get EmployeeID
cout << "Please enter employee ID: ";
cin >> empID[numberOfEmployees];
//get Employee Name into temporary variable, read it into permanent
cin.ignore(%2GW#J *p؆]O3 fhdwByGdc-)An{gFN
sp@/$y`