Your flowchart is quite confused and wrong. The only diamond I see where a decision should be made is at "Se EOF
". However, below it there are no two lines "Sim
" and "Não
" leaving. But in the boxes below, which as rectangles should represent instructions/assignments, there are a lot of "Sim
"s and "Não
"s coming out to various sides.
Note for example the box of "X > Y
". There are two written edges "Não
" going to her, and since there are no arrows, it is not possible to know which one I should choose.
Since "CODPRO
" is "X
" and "QTDMAX
" is "Z
", the little box "X <= Z
" that is to say "CODPRO <= QTDMAX
". Now, it is pointless to compare the code of a product with the quantity of that product. The other boxes "X > Y
", "X <= Y
" and "X == Z
" also do the same kind of meaningless operation. The only one that is on track is the "K = Z - W
".
Also, your algorithm doesn’t write to the file, it just uses the "Se EOF
" like I had to read from it.
Renaming variables as you did is a bad programming practice and only serves to cause confusion, even it seems that you have confused yourself. If I hadn’t made up that "CODPRO
" is "X
" and "QTDMAX
" is "Z
", you wouldn’t have written "X <= Z
".
Also, what is that "Não comprar
"? A written box "Comprar
" would even make sense as an action to be done, but a step of the algorithm specifying what it is not to do makes no sense at all. Also, your algorithm should not buy or stop buying anything, it should record information in the file.
I’m sorry to be blunt, but what you did is completely wrong. You can throw it all away and start over with a blank sheet.
Don’t confuse "logic" with "programming logic". Are different things.
– Victor Stafusa
This is supposed to be a flowchart?
– Victor Stafusa
I didn’t understand the comparisons with
X
if he’s just the product code.– Sam