Jump to content

Pseudocode problem help?

- - - - -

  • Please log in to reply
4 replies to this topic

#1
mirror1

mirror1

    Newbie

  • Members
  • Pip
  • 3 posts
Im a newbie to programming n barely started my class but my professor is already asking for too much.. I have other problems to do but this is one of them..


Here a problem
You will need to design an application that it will prompt a user for their hourly pay rate, their hours worked, and whether they are single, married, divorced, or widowed. It will then calculate their gross and net pay. If they work more than 40 hours, overtime is calculated at 1 ½ times the regular rate and displayed separately. If they are married, use a flat tax rate of 15%. If they are single, use 22%, if they are divorced, use 23%, and if they are widowed, use 13% (I realize that these are not very realistic). So how do i write this in a pseudocode and what would be the output? Any help would be appreciated thanks in advance

#2
gregwarner

gregwarner

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 853 posts
  • Location:Arkansas
Believe it or not, the work is 99% already done for you. That paragraph you wrote above that describes the problem? That can be classified as a type of pseudocode. Pseudocode is nothing more than an informal step by step description of the steps the program must take. First, it will prompt the user for their hourly pay rate. Then, it will prompt for their hours worked. Then, it will prompt for their marital status. Then, it calculates pay by following these steps: If the number of worked hours is over 40, then...

You might notice I'm doing nothing but restating what's already written up there. That's exactly what you'll be doing when you write your pseudocode. You'll just be writing the steps in a manner that looks kinda like computer instructions, like this for example:

print "What is your hourly pay rate?"

payrate = Get double from console.

That is another way of phrasing the instruction "Prompt the user for their hourly pay rate." The pseudocode takes one further step and mentions the name of the variable which is storing this value, which can be used later in a computation.

Hope that helps. Just take each individual instruction from the description paragraph and list them out, and it'll all start to make sense to you.
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.

– Douglas Hofstadter, Gödel, Escher, Bach: An Eternal Golden Braid


#3
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
Welcome aboard!
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#4
TheCompBoy

TheCompBoy

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 272 posts
Welcome to CodeCall!
Think my post we're usefull? Please take your time and press the Like button at my post, Big Thanks!
For great C# & Android tutorials visit my blogg: http://www.thecompboy.com/

#5
fread

fread

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 787 posts
Welcome to Codecall, mirror1! Post your questions in the programming subsections so other members can benefit. :thumbup:
Perfection of means and confusion of ends seem to characterize our age. Albert Einstein :confused:




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users