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
Why don't you want to use for loops? It's the natural option.
Moved to its own thread.
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
Yes, that would work. Just be sure to increment i as part of "statement"
Thank you!
Charlote
WingedPanther,
If I need some help with flowcharts, where do I look? I am having trouble with arrays actually. Can you help?
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?
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)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
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
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?
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?
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks