CIS17 - Logic Quiz

 

 

 

start

   amt1 = 1

   amt2 = 2

   ans = 0

   do while  amt2 < 15

      if amt1 > 10

         amt1 = amt1 + 1

         amt2 = amt2 + 1

      else

         amt1 = amt1 + 5

         amt2 = amt2 + 5

      end if

  end while loop

  ans = amt1 + amt2

  display ans

end     

 

Problem #1: When the pseudocode displays ans, what number will ans be?

 

1.     ans = 31

2.     ans = 29

3.     ans = 23

4.     ans = 27

5.     ans = 30

 

 

 

 

start

   amt1 = 1

   amt2 = 2

   ans = 0

   do until  amt2 > 15

      if amt1 > 10

         amt1 = amt1 + 1

         amt2 = amt2 + 1

      else

         amt1 = amt1 + 5

         amt2 = amt2 + 5

      end if

  end while loop

  ans = amt1 + amt2

  display ans

end     

 

Problem #2: When the pseudocode displays ans, what number will ans be?

 

1.     ans = 31

2.     ans = 29

3.     ans = 23

4.     ans = 27

5.     ans = 30

 

start

   amt1 = 1

   amt2 = 2

   ans = 0

   do while  amt2 < 15

      calculate()

   end while loop

   ans = amt1 + amt2

   display ans

end 

calculate()

      if amt1 > 10

         amt1 = amt1 + 1

         amt2 = amt2 + 1

      else

         amt1 = amt1 + 5

         amt2 = amt2 + 5

      end if

return   

Problem #3: When the pseudocode displays ans, what number will ans be?

 

1.     ans = 31

2.     ans = 29

3.     ans = 23

4.     ans = 27

5.     ans = 30

 

 

start

   read invenRecord

   do while not endOfFile

      totInven = onHand + onOrder

      if totInven > reOrdPt

           toOrder = 0

      else

           toOrder = (reOrdPt - (onHand + onOrder)) + 100

      end if

      display toOrder

      read invenRecord

   end do while loop

stop program

  

Inventory File where each record is invenRecord:

 

itemNo

onHand

onOrder

reOrdPt

11111

20

40

50

22222

30

10

50

33333

25

25

50

44444

10

50

100

55555

20

0

40

66666

5

25

25

EOF

 

 

 

Problem #4: Show the output that would be generated if this pseudocode was executed using the data shown.

 

start

   read invenRecord

   do while not endOfFile

      calcToOrder()

      display toOrder

      read invenRecord

   end do while loop

stop program

 

calcToOrder()

      totInven = onHand + onOrder

      if totInven > reOrdPt

           toOrder = 0

      else

           toOrder = (reOrdPt - (onHand + onOrder)) * 1.1

      end if

return

 

Problem #5: Using the same data that you used in problem #4, show the output that would be generated if this pseudocode was executed.

 

 

 

 

 

 

 

 

 

 

 

 

 

 


itemNo

onHand

onOrder

reOrdPt

11111

20

40

50

22222

30

10

50

33333

25

25

50

44444

10

50

100

55555

20

0

40

66666

5

25

25

EOF

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


Problem #6: Show the results that would be produced if this flowchart with its module or subroutine was executed.