Computer Programming

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

asked by Paul
  1. 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.

    posted by MathMate

Respond to this Question

First Name

Your Response

Similar Questions

  1. 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
  2. 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
  3. Programming

    Develop a Java application that will determine the gross pay for each of three employees. The company pays “straight line” for the first 40 hours worked by each employee and pays “time and a half” for all hours worked in
  4. 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
  5. 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
  6. programming

    write a program that creates a list of employees objects of size n entered from user using list interface and a list class implementation and display all employees in list and print employee name with minimum salary and remove
  7. programming MIPS ask

    Write a MIPS assembly language program that will cover the following steps: Prompt the user to enter a first integer named i1 Prompt the user to enter a second integer named i2 Compute i1+i2-200 Print the value of the result
  8. 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
  9. C programming

    Question: Write a program that reads integers from the keyboard until the user enters the sentinel value -999. The program should then print the minimum integer read, the maximum integer read and the average of all the integers.
  10. Java

    You are to create an efficient OO application to be used by the wait staff at the Mason Inn. You will process one waiter/waitress at a time. The user will provide information for him or her, to include: their name, number of hours

More Similar Questions