Post a New Question

Computer Programming

posted by .

I need a check on my answers

1) prompt a user to enter an employee name, employee id, and hours worked until a value of "-1" is entered for employye name.
my answer:
Start
Declarations
num EmployId, HrsWrked
string EmployName
housework()
detailLoop()
Stop

housework()
output "Please enter Employee Name"
input EmployName
output "Please enter Employee ID number"
input EmployId
output "Please enter Hours Worked"
input HrsWrked
return

detailLoop()
check if EmployName = -1
while EmployName < > -1
output "Please enter Employee Name"
input EmployName
output "Please enter Employee ID number"
input EmployId
output "Please enter Hours Worked"
input HrsWrked
check if EmployName = -1
endwhile
return


2) If the employee id is not between 1 and 599, continue to prompt the user until a valid employee id is entered.
my answer:
Start
Declarations
num EmployId, HrsWrked
string EmployName
housework()
detailLoop()
Stop

housework()
output "Please enter Employee Name"
input EmployName
output "Please enter Employee ID number"
input EmployId
output "Please enter Hours Worked"
input HrsWrked
return

detailLoop()
check if EmployName = -1
while EmployName < > -1
check if EmployID is >= 1 and <= 599
if EmployID is <1 or > 599
output "Incorrect Employee ID number, Please enter ID value 1- 599"
input EmployId
endif
output "Please enter Employee Name"
input EmployName
output "Please enter Employee ID number"
input EmployId
output "Please enter Hours Worked"
input HrsWrked
check if EmployName = -1

endwhile
return

  • Computer Programming -

    If I were to code this program, I would start from the user's point of view, namely start appropriate action as soon as possible, such as when an error is discovered.

    For the first part, the code is generally correct, but I suggest making change to avoid the following dialog:

    Please enter Employee Name
    -1
    Please enter Employee ID number
    123456789
    Please enter Hours Worked
    0
    Goodbye

    Once the Employee Name is entered as -1, users expect to either quit the program or see the "goodbye" message.
    They would be wondering what's the point of entering EmployeeID and hours worked, which are no longer relevant.

    For number 2, it's a similar comment. In addition, the entry of EmployeeID can be modified to let the user immediately correct the ID right after he entered an invalid one, such as:


    output "Please enter Employee ID number"
    input EmployId
    while EmployID is <1 or > 599
    output "Incorrect Employee ID number, Please enter ID value 1- 599"
    input EmployId
    endwhile

    This will take care of the problem on the spot.

    Otherwise, the pseudocode looks quite logical.

Respond to this Question

First Name
School Subject
Your Answer

Similar Questions

  1. programing

    A small startup software developer company needs to create a program that will calculate the pay of its employees. For the third version of the program, the company wants the program to accept an employee’s name, the number of hours …
  2. programing

    small startup software developer company needs to create a program that will calculate the pay of its employees. For the third version of the program, the company wants the program to accept an employee’s name, the number of hours …
  3. devry

    A small startup software developer company needs to create a program that will calculate the pay of its employees. For the third version of the program, the company wants the program to accept an employee’s name, the number of hours …
  4. computer Programming

    A small startup software developer company needs to create a program that will calculate the pay of its employees. For the third version of the program, the company wants the program to accept an employee’s name, the number of hours …
  5. computer programming

    small startup software developer company needs to create a program that will calculate the pay of its employees. For the third version of the program, the company wants the program to accept an employee’s name, the number of hours …
  6. programming logic

    Find Bugs in the pseudocode // A high school is holding a recycling competition // This program allows a user to enter a student's // year in school (1 through 4) // and number of cans collected // Data is entered continuously until …
  7. programming

    write a payroll program that promt a user to enter his name,hourly rate,working hours in the week and display the amount earning by each employee in Rand.user is not allowed to enter any negative value for hourly rate and working hours.
  8. Programming with Eclipse

    Design, implement, test, and debug an application to compute an employee’s weekly pay. If the employee works more than 40 hours a week, the employee earns 1.5 times the basic hourly pay for any time worked over 40 hours. The program …
  9. programming

    using pseudocode debug the following 3 programs // A high school is holding a recycling competition // This program allows a user to enter a student's // year in school (1 through 4) // and number of cans collected // Data is entered …
  10. programming

    Temp Employer wants a program that will allow the company’s clerk to enter an employee’s name and the number of hours the employee works every month. (The number of hours worked will always be an integer). The program will display …

More Similar Questions

Post a New Question