Closed Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Re: Pseudocode Tutorial: The Basics - spawned question

  1. #1
    charlote is offline Newbie
    Join Date
    Feb 2010
    Posts
    29
    Rep Power
    0

    Exclamation Re: Pseudocode Tutorial: The Basics - spawned question

    Need help with pseudocode problem:

    Here is the question?
    Secondhand Rose Resale shop is having a 7 day sale during which the price of any unsold item drops 10% each day. The inventory File includes an item number, description, and original price on day one. For example, an item that costs $10.00 on the 1st day costs 10% less, or $9.00, on the 2nd day. On the 3rd day the same item is 10% less than $9.00 or $8.10. Design an application that reads inventory records and produces a report that shows the price of every item on each day, one through seven.

    What I have done so far is :

    Open inventory File
    Read one record in inventory File
    while there are still records in the inventory file

    Price = record.Original_Price
    for i = 1 to 7
    print price for day, i
    print record_ItemNumber, description, price
    price = price * 0.9


    Am I doing it right.? The problem is I don't want to use For Loop here.
    Can anyone help me with this?
    Thanks,
    Charlotte

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Join Date
    Jul 2006
    Posts
    16,494
    Blog Entries
    75
    Rep Power
    143

    Re: Pseudocode Tutorial: The Basics - spawned question

    Why don't you want to use for loops? It's the natural option.

    Moved to its own thread.
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  4. #3
    charlote is offline Newbie
    Join Date
    Feb 2010
    Posts
    29
    Rep Power
    0

    Re: Pseudocode Tutorial: The Basics - spawned question

    Hi!

    ITA. For loop would be the best option.
    Just trying different options. Moreover I have been asked to use while loop..

    In that case, would this be correct?

    while i<=7
    do(statement)
    endwhile

    my question is if I use the "price = price*0.9" would it work? would it automatically take 2nd day's price to calculate 3rd day's discount?

    Thank you,
    Charlotte

  5. #4
    Join Date
    Jul 2006
    Posts
    16,494
    Blog Entries
    75
    Rep Power
    143

    Re: Pseudocode Tutorial: The Basics - spawned question

    Yes, that would work. Just be sure to increment i as part of "statement"
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  6. #5
    charlote is offline Newbie
    Join Date
    Feb 2010
    Posts
    29
    Rep Power
    0

    Re: Pseudocode Tutorial: The Basics - spawned question

    Thank you!

    Charlote

  7. #6
    charlote is offline Newbie
    Join Date
    Feb 2010
    Posts
    29
    Rep Power
    0

    Re: Pseudocode Tutorial: The Basics - spawned question

    WingedPanther,

    If I need some help with flowcharts, where do I look? I am having trouble with arrays actually. Can you help?

  8. #7
    Join Date
    Apr 2009
    Location
    Trapped in my own little world.
    Posts
    2,487
    Rep Power
    33

    Re: Pseudocode Tutorial: The Basics - spawned question

    Post any questions in the forum and tons of members would be happy to assist you with your flow chart and array problem.

    What exactly are you having issues with?

  9. #8
    charlote is offline Newbie
    Join Date
    Feb 2010
    Posts
    29
    Rep Power
    0

    Re: Pseudocode Tutorial: The Basics - spawned question

    here is my code,
    Code:
    start
      num teamNum
      string firstName
      string lastName
      num SIZE = 5
      string teams[SIZE] = "Goal Getters", "The Force", "Top Guns", "Shooting Stars", "Midfield Monsters"
      read firstName, lastName, teamNum
      while not eof
            if teamNum ?=1 AND teamNum <= SIZE then
                 print firstName, lastName, teamNum, teams[teamNum-1]
            else 
                 print "Invalid team Number"
            endif
            get firstName, lastName, teamNum
        endwhile
    (This code is to read the data from the file and to create a report that lists each player along with his team number and team name)
    I want to modify this one to count the total number of players in each team (using the read data) and display/print list of players in each team( display /print total count in each team and team name)
    how do I use subscript in print module? Do I need to use individual team name?


    To count I actually did the following:
    Code:
    num teamCount [SIZE] = 0
      If teamNum >= 1 AND teamNum<= SIZE then
           teamCount[teamNum-1] = teamCount[teamNum-1] +1
      else
         print "Invalid team number"
      endif
      read firstName,lastName, teamNum
    endwhile
    while teamNum<SIZE
       print teamNum+1, teamCount[teamNum], teams???(this is where I don't know how to display/print teamName?)
       teamNum = teamNum + 1
     endwhile
    stop
    Last edited by WingedPanther; 03-07-2010 at 05:42 PM. Reason: add code tags

  10. #9
    Join Date
    Jul 2006
    Posts
    16,494
    Blog Entries
    75
    Rep Power
    143

    Re: Pseudocode Tutorial: The Basics - spawned question

    You've got an endwhile without a while...
    I think you need a two-dimensional array to hold the team members. Do you have a spec on the file format?
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  11. #10
    Join Date
    Jul 2006
    Posts
    16,494
    Blog Entries
    75
    Rep Power
    143

    Re: Pseudocode Tutorial: The Basics - spawned question

    You've got an endwhile without a while...
    I think you need a two-dimensional array to hold the team members. Do you have a spec on the file format?
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

Closed Thread
Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Pseudocode Tutorial: The Basics
    By TcM in forum Tutorials
    Replies: 31
    Last Post: 11-22-2011, 09:48 AM
  2. Re: Pseudocode Tutorial: The Basics
    By hahahehe in forum General Programming
    Replies: 2
    Last Post: 08-15-2011, 08:36 AM
  3. Re: Pseudocode Tutorial: The Basics
    By rageoutfool in forum General Programming
    Replies: 3
    Last Post: 09-04-2010, 12:12 PM
  4. Re: Pseudocode Tutorial: The Basics
    By mkcrider in forum General Programming
    Replies: 1
    Last Post: 05-07-2010, 12:10 PM
  5. Begginer In need of pseudocode tutorial help
    By jason007thomas in forum Introductions
    Replies: 9
    Last Post: 11-07-2008, 05:03 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts