31.3k views
4 votes
// This pseudocode is intended to display // employee net pay values. All employees have a standard // $45 deduction from their checks. // If an employee does not earn enough to cover the deduction, // an error message is displayed. // This example is modularized. start Declarations string name string EOFNAME = "ZZZZ" while name not equal to EOFNAME housekeeping() endwhile while name not equal to EOFNAME mainLoop() endwhile while name not equal to EOFNAME finish() endwhile stop housekeeping() output "Enter first name or ", EOFNAME, " to quit " return mainLoop() Declarations num hours num rate num DEDUCTION = 45 num net output "Enter hours worked for ", name input hours output "Enter hourly rate for ", name input rate gross = hours * rate net = gross - DEDUCTION if net > 0 then output "Net pay for ", name, " is ", net else output "Deductions not covered. Net is 0." endif output "Enter next name or ", EOFNAME, " to quit " input name return finish() output "End of job" return

User Nisson
by
3.4k points

2 Answers

4 votes

Final answer:

The pseudocode represents a program to calculate employee net pay after deductions. Translated examples in both C++ and Python follow the provided logic, handling user inputs and conditions to display the calculated net pay or error messages where deductions are not covered.

Step-by-step explanation:

The pseudocode provided is intended to calculate and display the net pay for employees after a standard deduction of $45. If the employee's gross income is not enough to cover the deduction, an error message will be displayed. To demonstrate this logic in popular programming languages, let's write complete code in C++ and Python.

Example in C++:

\ C++ code example
#include
#include
using namespace std;

int main() {
const double DEDUCTION = 45.0;
string name;
double hours, rate, net;
cout << "Enter first name or ZZZZ to quit: ";
while (cin >> name && name != "ZZZZ") {
cout << "Enter hours worked for " << name << ": ";
cin >> hours;
cout << "Enter hourly rate for " << name << ": ";
cin >> rate;
net = hours * rate - DEDUCTION;
if (net > 0) {
cout << "Net pay for " << name << " is " << net << endl;
} else {
cout << "Deductions not covered. Net is 0." << endl;
}
cout << "Enter next name or ZZZZ to quit: ";
}
cout << "End of job" << endl;
return 0;
}

Example in Python:

\ Python code example
name = input("Enter first name or ZZZZ to quit: ")
DEDUCTION = 45

while name != "ZZZZ":
hours = float(input(f"Enter hours worked for {name}: "))
rate = float(input(f"Enter hourly rate for {name}: "))
gross = hours * rate
net = gross - DEDUCTION
if net > 0:
print(f"Net pay for {name} is {net}")
else:
print("Deductions not covered. Net is 0.")
name = input("Enter next name or ZZZZ to quit: ")

print("End of job")

User Nyavro
by
3.9k points
7 votes

Answer:

C++ code is given below

Step-by-step explanation:

#include<iostream>

#include <cstring>

using namespace std;

int housekeeping(string EOFNAME);

int mainLoop(string name,string EOFNAME);

int finish();

void main()

{

string name;

string EOFNAME = "ZZZZ";

cout << "enter the name" << endl;

cin >> name;

if (name != EOFNAME)

{

housekeeping(EOFNAME);

}

if (name != EOFNAME)

{

mainLoop(name , EOFNAME);

}

if (name != EOFNAME)

{

finish();

}

system("pause");

}

int housekeeping(string EOFNAME)

{

cout << "enter first name " << EOFNAME << " to quit " << endl;

return 0;

}

int mainLoop(string name, string EOFNAME)

{

int hours;

int rate,gross;

int DEDUCTION = 45;

int net;

cout << "enter hours worked for " << name << endl;

cin >> hours;

cout << "enter hourly rate for " << name << endl;

cin >> rate;

gross = hours*rate;

net = gross - DEDUCTION;

if (net > 0)

{

cout << "net pay for " << name << " is " << net << endl;

}

else

{

cout << "dedections not covered.net is 0.";

}

cout << "enter next name or " << EOFNAME << " to quit" << endl;

cin >> name;

return 0;

}

int finish()

{

cout << "end of job"<<endl;

return 0;

}

User Ben Von Handorf
by
3.6k points