Algorithm with flowchart / diagram

Guys, I'm doing a logic course and dropped the following Question:

Draw a block diagram to verify which products need to be purchased and the quantity to be purchased: having the following information:

  • Product code (CODPRO), minimum quantity (QTDMIN), maximum quantity (QTDMAX) and the quantity in stock (QTDEST) of each product.

  • A product should only be purchased when: quantity in stock is less than or equal to the minimum quantity: QTDBUY = (QTDMAX – QTDEST)

  • Save to another file: Product Code and quantity to buy

I did so, and I wonder if I'm more or less on the right track or completely off course and why?

diagram

Author: Victor Stafusa, 2017-12-08

2 answers

In addition to the problems reported in the first answer, this diagram shows how the flow of comparisons would be, where NÃO means that one of the comparisons were not met, therefore valid, and SIM that were met, are not valid.

In the case (k > z) ou (k < y) ou (k > w), i.e., respectively:

  • (k > z): the purchase quantity is greater than the maximum quantity;

  • (k < y): the purchase quantity is less than the minimum quantity, e

  • (k > w): the purchase quantity is greater than the quantity in stock.

The Se não x (EOF) ou x (EOF) checks whether the product code exists or does not exist.

codpro = x;
qtdmin = y;
qtdmax = z;
qtdest = w;
qtdcompra = k;

         Se não x (EOF)    ou    x (EOF)
              |                     |
---------------------------------   |
(k > z)  ou  (k < y)  ou  (k > w)   |
---------------------------------   |
          |    |                    |
         NÃO  SIM--------           |
          |             |           |
      [COMPRAR]   [NÃO COMPRAR]------
          |             |
        [FIM]------------
 2
Author: Sam, 2017-12-09 23:07:45

Your flowchart is pretty confusing and wrong. The only Rhombus I see where a decision should be made is in the "Se EOF". However, below it there are no two lines "Sim" e "Não" coming out. But in the boxes below, which as rectangles should represent instructions/assignments, there are a lot of "Sim"s e "Não"s coming out to several sides.

Note For example the "X > Y". There are two edges written "Não " going to her, and since there are no little bristles, you can not know which one I should choose.

Since "CODPRO" it is "X" and "QTDMAX" it is "Z", in the box "X <= Z" you want to say "CODPRO <= QTDMAX". Now, it makes no sense to compare the code of a product with the quantity of that product. The other boxes "X > Y", "X <= Y" e "X == Z" they also do the same kind of meaningless operation. The only that is on the right 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 him.

To be renaming variables like 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 invented that "CODPRO" is "X" e "QTDMAX" is "Z", you wouldn't have written "X <= Z".

And also, what is that "Não comprar"? A written box"Comprar" it would even make sense as an action to be done, but an algorithm step specifying what it is not to do makes no sense at all. Also, your algorithm should not buy or stop buying anything, it should write an information to the file.

Sorry for the sincerity, but what you did is completely wrong. Can throw it all away and start over with a blank sheet.

 1
Author: Victor Stafusa, 2017-12-09 00:19:49