Algorithms Assistance Needed

Discussion in 'The Guru's Pub' started by Einahpets Gynn, Jan 13, 2011.

  1. Hey fellow Guru-ers

    I missed my first C++ introduction class last week cause I was ill and I have some homework to submit and I am clueeeeless

    Can anyone help me out? or atleast understand this?
    I need to write a pseudo code for the following.

    Jenna Williams is paid based on an annual salary rather than an hourly wage. She wants a program that calculates the amount of her gross spay for each pay period. Construct a pseudo code for this problem. Desk-check the algorithm using $35,000 as the annual salary and 52 as the number of pay periods. Then desk-check it using $50,000 as the annual salary and 24 as the number of pay periods.


    The accountant at Typing Haven wants a program that will help her prepare a customer's bill. She will enter the number of typed envelopes and then number of typed pages, as well as the charge per typed envelope and the charge per typed page. The program should calculate and display the amount due for the envelopes, the amount due for the pages, and the total amount due. Complete an IPO chart for this problem. Desk-check the algorithm using 50, 100, $.10, and $.25 as the number of typed envelopes, the number of typed pages, and the charge per typed envelope, and the charge per typed page. Then desk-check it using your own set of data.

    This............
    Looks like greek to me at the moment
    Can anyone help out?
    Thanks :D
     
  2. __hollywood|meo

    __hollywood|meo Ancient Guru

    Messages:
    2,991
    Likes Received:
    139
    GPU:
    6700xt @2.7ghz
    no :p
     
  3. G-Man

    G-Man Maha Guru

    Messages:
    1,030
    Likes Received:
    0
    GPU:
    Sparkle 8800GTS 640MB
    How little do you know? the code doesn't look like it'll be that hard...

    now im not gonna do your homework for you, but you would be using cout to output text, and cin to capture input and then you would just use the inputted variables in the algorithm. surely you can work the algorithms out yourself, they are quite simple atm... and operators are pretty much the same as when doing any maths on a computer (* = multiply, / = divide, % = remainder, etc...)
     
  4. heads_up

    heads_up Ancient Guru

    Messages:
    3,510
    Likes Received:
    0
    GPU:
    Sapphire 5770 1GB
    No one will do it for you, but surely being the g3d I know someone will lend a hand.

    Not me though, I don't know **** about C++
     

  5. Dustpuppy

    Dustpuppy Ancient Guru

    Messages:
    4,146
    Likes Received:
    0
    GPU:
    integrated - fffffffuuuuu
    I'd never heard the term "desk check" used before. Apparently it just means to step through the algorithm on paper using test data? I think I recall doing that as a freshman once or twice.

    However, regardless you're going to lose points if you've got a strict teacher. Most people have their own style of psuedocode so without seeing exactly what your teacher wants you to write the most I can tell you is to just verbally describe the mathematical steps, io prompts, & variable assignments.

    I recommend googling examples of psuedocode, CS IPO Charts, and desk checking.
     
  6. proliferazor

    proliferazor Master Guru

    Messages:
    684
    Likes Received:
    1
    GPU:
    AMD 7950
    these are simple math problems here.
     
  7. PuddingWagon

    PuddingWagon Guest

    Messages:
    1,087
    Likes Received:
    0
    GPU:
    Gigabyte GTX 670
    I think you just need to take a step back and think about these questions for a second, they really are just basic arithmetic. The best thing to do would be to go in and ask your lecturer about it. All the lecturers I've had are more than happy to help you catch up, especially if you were actually sick.

    Making more sense? It's just problem solving, no programming knowledge required.
     
  8. I didn't ask if anyone could do the homework assignment for me, I asked if someone could help me understand. I did some reading though, desk-check seems to mean to use the provided (or not) data to verify the steps of the algorithm :) and at my college they're very understanding, I will get help from the professor that's expected, I wanted to have someone assist me in understanding how to go about writing one before class..ya know..waste less time? Unfortunately PuddingWagon was the only one who seemed to understand that. Thanks pudding.

    @Pudding, actually thanks alot though, I'm trying to understand it for myself and I'm making progress, you simplified it XD. I understand..HOW to come up with the answers, I'm just not certain as to what to write down. It's not rocket science, for example they want to know how much she is paid at the end of one pay period (gross)
    Thats just $35,000/52 = $673, which is what she'd get paid for one pay period.
    and for the second part it's $50,000/24 = $2083
     
  9. PuddingWagon

    PuddingWagon Guest

    Messages:
    1,087
    Likes Received:
    0
    GPU:
    Gigabyte GTX 670
    Ah rightio, you can never be too sure about people and homework :p

    Desk checking is exactly as you said, just verifying the algorithm manually. Helpful in exams :) Actually useful when first developing a solution to verify it and later when it doesn't work as you thought it should; you narrow down the mistake to the algorithm or the code and then find it.


    Pseudo-code is just writing down what steps are required to complete the task in a more structured language than normal English. In this case it'd be something like:
    Code:
    INPUT <variables needed, e.g. revenue, cost>
    <processing/arithmetic, e.g. profit = revenue - cost>
    OUTPUT <results, e.g. profit>
    
    (<words> means 'replace this with actual stuff')
    i.e. Get your inputs, process them to give the outputs (IPO).
    Pseudocode doesn't always have to be INPUT->OUTPUT, it just depends on what it's trying to describe.

    Think about what you'd put in there, giving variables useful names. Below is a possible answer to check yours against if you want one.
    Code:
    INPUT yearly_earnings, number_of_pay_periods
    earnings_per_period = yearly_earnings / number_of_pay_periods
    OUTPUT earnings_per_period
    
    Don't read into how I named the variables btw.

    IPO model is pretty much showing this graphically, and almost always without showing how to accomplish the processing (a black box since you can't see inside to know the how, in contrast to a white/glass box where you can). One side of the box are the inputs (arrows going in), then a box (its label indicates what it does - e.g. "calculate profit"), then outputs at the other side of the box (arrow out). Ignore the storage bit. Your lecturer should have a nice way of explaining this, with drawing.
     
  10. Tat3

    Tat3 Ancient Guru

    Messages:
    11,863
    Likes Received:
    238
    GPU:
    RTX 4070 Ti Super
    I dont know about IPO chart, but, she will give you number of envelopes and price, total for envelopes is easy to count.
    Then she will give you amount of pages and price per page, total for pages is easy to count.

    Price for both should not be hard either.

    Code:

    [​IMG]

    How it looks like:

    [​IMG]

    EDIT: Darn, seems to be typo there. Was ment to be "Here we show values to user which we counted"
     
    Last edited: Jan 13, 2011

  11. Hahah interesting names, I used annual salary and pay periods I think, Thanks a million though, you saved me a bunch. Thanks to your explanations I understood more than I anticipated than I would, I only also just got the text today, so I'm doing a few as practice, and I'm hitting myself on the head with a brick wondering how in the world did I not understand this 24 hours ago.

    @Tat3, Wow...I book marked the page for so I can try to understand it completely tomorrow, very thorough though, Thanks a mill man.
     
  12. Dustpuppy

    Dustpuppy Ancient Guru

    Messages:
    4,146
    Likes Received:
    0
    GPU:
    integrated - fffffffuuuuu
    What textbook are you guys using? If you don't mind my asking.
     

Share This Page