Question

Pseudocode and Flowchart: Program that stops production whenever there is a run of four consecutive pills...

Pseudocode and Flowchart:

Program that stops production whenever there is a run of four consecutive pills that have a content of Ibuprofen above, or four consecutive pills with a level below 129.

Also use these two modules in your code:

  • machineOFF()is a module that turns off the machine when is executed.
  • getIbuprofen()is a module that returns the value of Ibuprofen from the current pill or 0 if this is the last pill.

Please make sure to use the following additional instructions:

  • Do not code or chart the two modules machineOFF()and getIbuprofen(). Think of them as built-in functions. This is a very common element of programming
  • To stop production, the values must be consecutively above or below the number. For example, if the value is 350, then the sequence 360, 351, 470, 329 would not stop the machine because the first three numbers are above but the fourth is below. A run of 300, 312, 333, 349 would stop the machine since they are all below
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Pseudocode for a machine that stops production whenever there is a run of four consecutive pills that have a content of Ibuprofen above, or four consecutive pills with a level below 129.

Declaration
   number pills_Ibuprofen ;
   number pills_above_129;
   number pills_below_129;
  
Start
   // Initialize pills_above_129 and pills_below_129 to 0 at the start of the program
   pills_above_129 = 0;
   pills_below_129 = 0;
   pills_Ibuprofen = getIbuprofen(); // call and get the current Ibuprofen for the pill produced

   // the loop continues till we get the last pill or
   // Ibuprofen of number of pills produced consecutively is greater than 129 or
   // Ibuprofen of number of pills produced consecutively is less than 129
   while(pills_Ibuprofen != 0 and pills_above_129 < 4 and pills_below_129 < 4)  
   do
       // check if Ibuprofen of the pill is less than 129, greater than 129 or equal to 129 and set pills_above_129 and pills_below_129 accordingly

       if(pills_Ibuprofen > 129) then
           pills_above_129 = pills_above_129 + 1;
           pills_below_129 = 0;
       else if(pills_Ibuprofen < 129) then
           pills_above_129 = 0;
           pills_below_129 = pills_below_129 + 1;
       else  
           pills_above_129 = 0;
           pills_below_129 = 0;
       end if;

       pills_Ibuprofen = getIbuprofen(); //call and get the current Ibuprofen for the pill produced

   end while;
   machineOFF(); // if the program comes out of the loop then switch off the machine.
End  

//end of pseudocode

Flowchart:

Add a comment
Know the answer?
Add Answer to:
Pseudocode and Flowchart: Program that stops production whenever there is a run of four consecutive pills...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • need help to complete this java program // add appropriate import statements here. // These imports...

    need help to complete this java program // add appropriate import statements here. // These imports you can leave as is. import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.canvas.Canvas; import javafx.scene.canvas.GraphicsContext; import javafx.scene.paint.Color; import javafx.stage.Stage; /** @author yourAccountNameHere */ public class ConnectTheDots extends Application {            /*     * Do not add code to main(). Add it below in connectTheDots instead.     */     public static void main(String[] args) {         launch(args);     }         /*...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT