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

  1. 👍 0
  2. 👎 0
  3. 👁 30
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.

    1. 👍 0
    2. 👎 0
    posted by MathMate

Respond to this Question

First Name

Your Response

Similar Questions

  1. 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

    asked by jack on November 11, 2012
  2. Multimedia

    Not sure if you will get this right away.. but here is the question... Prompt the user for their name and then prompt the user for a number between 1 and 12. After getting the input, you will display the user’s name and then

    asked by Nikki on September 13, 2015
  3. computer science

    You are required to use the Account class to simulate an ATM machine. Create ten accounts in an array with id 0, 1, 2 ...9, and initial balance $50. The system prompts the user to enter an id. If the id is entered incorrectly, ask

    asked by karen on March 13, 2013
  4. Computer Science

    Write a program that Will prompt a user to enter his/her name and number.use a while loop that will display the user name times the entered number

    asked by Tom on October 27, 2016
  5. computer Science (need answer ASAP)

    Write a complete C# program that displays a menu comprising of the followings: Main Menu 1) Calculate Fuel Consumption 2) Calculate Weekly Wages 3) About This Program 4) Exit Program Enter your Choice: Calculating Fuel Consumption

    asked by Will on March 6, 2011
  6. computer science

    Write a complete C# program that displays a menu comprising of the followings: Main Menu 1) Calculate Fuel Consumption 2) Calculate Weekly Wages 3) About This Program 4) Exit Program Enter your Choice: Calculating Fuel Consumption

    asked by Will on March 7, 2011
  7. Computer Programming

    Create the flowchart and algorithm for a module that will prompt the user to enter the amount of cash they have in their pocket. The program should output “Not Enough” ($0 - $0.64), “Vending Machine” ($0.65 - $1.99),

    asked by Janet on October 27, 2014
  8. Java Programming

    I am trying to finish this final problem on my Java homework. Due to a death in the family I've missed a class and now am trying to get back on track. Write a driver class called GasPumpDriver that meets the following

    asked by Jay on February 14, 2016
  9. C Programming

    Write a program that prompts the user to enter a temperature, followed by a letter representing Celsius (C) or Fahrenheit (F). Then prompt the user for the conversion type and print the results to the screen with one decimal

    asked by gnozahs on September 24, 2009
  10. Computer Science/Pseudo Code Python

    Hi, I'm confused about an assignment. I'm not sure what to do and would like some help. An example: Write a program that obtains two integer numbers from the user. It will print out the sum of those numbers. Pseudo code: Prompt

    asked by Rain on February 28, 2016

More Similar Questions