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
Re: Pseudocode Tutorial: The Basics - spawned question
Started by charlote, Mar 01 2010 10:33 AM
11 replies to this topic
#1
Posted 01 March 2010 - 10:33 AM
|
|
|
#2
Posted 02 March 2010 - 08:24 PM
Why don't you want to use for loops? It's the natural option.
Moved to its own thread.
Moved to its own thread.
#3
Posted 03 March 2010 - 07:35 AM
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
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
#4
Posted 03 March 2010 - 08:13 AM
Yes, that would work. Just be sure to increment i as part of "statement"
#5
Posted 03 March 2010 - 10:24 AM
Thank you!
Charlote
Charlote
#6
Posted 07 March 2010 - 01:55 PM
WingedPanther,
If I need some help with flowcharts, where do I look? I am having trouble with arrays actually. Can you help?
If I need some help with flowcharts, where do I look? I am having trouble with arrays actually. Can you help?
#7
Posted 07 March 2010 - 02:18 PM
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?
What exactly are you having issues with?
#8
Posted 07 March 2010 - 03:56 PM
here is my code,
(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:
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:
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
Edited by WingedPanther, 07 March 2010 - 05:42 PM.
add code tags
#9
Posted 07 March 2010 - 05:48 PM
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?
I think you need a two-dimensional array to hold the team members. Do you have a spec on the file format?
#10
Posted 07 March 2010 - 05:49 PM
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?
I think you need a two-dimensional array to hold the team members. Do you have a spec on the file format?
#11
Posted 07 March 2010 - 06:00 PM
I am just learning the basics(pseudo code and flowchart). I don't have any spec on file format. I think "endwhile" was my mistake.
num teamCount [SIZE] = 0
read firstName, lastName, teamNum
while not eof
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
Would this be correct one?
Thanks for your quick reply
I forgot to ask how do I upload the flowchart file? Can I just attach the VISIO files here?
num teamCount [SIZE] = 0
read firstName, lastName, teamNum
while not eof
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
Would this be correct one?
Thanks for your quick reply
I forgot to ask how do I upload the flowchart file? Can I just attach the VISIO files here?
Edited by Vswe, 08 March 2010 - 05:11 AM.
Don't double post, edit instead.
#12
Posted 08 March 2010 - 06:22 PM
Please use code tags (the # button) and indentation to make your pseudocode readable.


Sign In
Create Account


Back to top










