Pseudocode Help, Very Easy, Just not for me!

Discussion in 'Programming' started by Techage, Feb 13, 2009.

  1. Techage

    Techage New Member

    Joined:
    Feb 13, 2009
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Ok I'm deffinatly not sure if I should post this here, but I have looked all over for help and can't find a thing! I'm currently enrollled in a Programming Logic and Design course, we have only read 3 chapters, and the teacher wnats us to write pseudocode. I don't know how to do any of this! I'm read these chapters so many times and I understand how to read the pseudocode, and even can find errors, but I just can't figure out how to start from scratch! Soo I need some help on this, I'm not asking for the answer, just maybe how to start? I'd really appreciate it.


    8) All in a Day’s Work is a temporary employment agency. The manager needs to determine how much tax to withhold for each employee. This withholding amount computes as 20 percent of each employee’s weekly pay. The weekly pay is the hourly pay time 40.
    A) Design an interactive screen that displays an employee’s weekly pay and withholding amount. The user inputs the hourly pay rate for an employee. Draw the flowchart or write the pseudocode for this program.
    B) Design a printed report titled WITHOLDING FOR EACH EMPLOYEE. Input fields include the first and last names of each employee, hourly pay, weekly pay, and withholding amount per week. Draw the flowchart or write the pseudocode for this program.
    For (B) I have this, but I'm sure I did it incorrect, and I don't even know where to start on (A). I tired to get teh teacher to help me, but hes a grumpy old man and doesn't want anything to do with his students.

    8 –B
    Printchart:
    WITHOLDING FOR EACH EMPLOYEE
    LAST NAME FIRST NAME HOURLY PAY WEEKLY PAY WITHOLD
    XXXXXXXXX XXXXXXXXX XXXXXXXXX XXXXXXXX XXXXXXX
    XXXXXXXXX XXXXXXXXX XXXXXXXXX XXXXXXXX XXXXXXX
    XXXXXXXXX XXXXXXXXX XXXXXXXXX XXXXXXXX XXXXXXX

    END OF REPORT


    Pseudocode


    start
    char employeeLast
    char employeeFirst
    num employeeHourly
    num employeeWeekly
    num withHold
    string HEAD = “WITHOLDING AMOUNT FOR EACH EMPLOYEE”
    string COL_HEADS = “LAST NAME FIRST NAME HOURLY PAY WEEKLY PAY WITHOLD”
    string FOOT = “END OF REPORT”
    print HEAD
    print COL_HEADS
    get employeeLast, employeeFirst, employeeHourly, employeeWeekly, withHold
    while not eof
    employeeWeekly = employeeHourly *40
    withHold = employeeWeekly * .2
    print employeeLast, employeeFirst, employeeHourly, employeeWeekly, withHold
    get employeeLast, employeeFirst, employeeHourly, employeeWeekly, withHold
    endwhile
    print FOOT
    end


    Like I said, thanks again.
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    The main thing about pseudocode (academic nonsense aside) is that it's a flexible tool intended to get your thoughts straight about how the program is going to work without tying you up in all the tedious syntax rules that compilers can insist on and that can distract you from what you're trying to do.

    In fact I'd even suggest that the pseudocode above is too detailed. We don't need to know what type employeeWeekly is; that will be obvious from the context. Unless there's a reason for specifying it just leave it out. Also if we just said FOOT = “END OF REPORT” then it would be obvious that FOOT was some kind of character/string type.

    It doesn't need to look much like program code. Just write your thoughts out in a semi structured way. If you think of something that should be "inserted", just draw arrows indicating the flow.

    So in a way it's similar to flowcharting, although even flowcharting has its "syntax rules" that can get in the way.

    So there are no rules really. I can't tell you how to write pseudocode just as I can't tell you how to write your reply to this comment. Just write out how you think the program is going to work, then by looking over that you can "debug" it and get the ideas straight. Once you've got the ideas straight you can then translate it into program code step by step and hopefully it should work without too much hassle. As with everything the more experience you have the more "correct" the pseudocode will be, so the only way to learn is by doing it and translating it into code.

    For what it's worth I think your teacher knows his stuff. Pseudocode is really useful. And maybe being grumpy is just a way to get you to do your own work.
     
    shabbir likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice