Advertisement
mrScarlett

Task 1 - PreRelease - 2018 V1.1

Jan 29th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. INPUT noCows // Input number of cows in a herd
  2.  
  3. cowIds = [1:noCows] // Array to store IDs, the length will be dependent on the noCows input.
  4. totalYield = [1:noCows] // Array to store the total milk from each cow over the 7 days.
  5. idLength = 3 // Constant used for validation of cow ID (the ID length should be 3 numbers)
  6.  
  7. FOR day = 1 to 7 // Loop for 7 days
  8.  
  9. FOR cow = 1 to noCows // Loop for number of cows
  10. IF day == 1 // If day 1 then the cow ID should be entered,
  11. id=0 // Initialising id to 0 (not 3 digits long)
  12. WHILE length(id) != idLength // Checks if the id length is 3 digits
  13. OUTPUT "Enter Cow ID"
  14. INPUT id // Prompt to enter ID at the beginning as the length is currently 1(id=0)
  15. END WHILE
  16. cowIds[cow] = id //Once the ID entered is 3 digits long then it will be added to the cowsIds array.
  17. totalYield[cow]=0
  18. END IF
  19.  
  20. dailyMilk=0 // dailyMilk set to 0 before loop below
  21. FOR milking = 1 to 2 // loop for 2 milk readings a day
  22. OUTPUT "Milk Reading "+milking
  23. INPUT milkAmount
  24. dailyMilk+=milkAmount // dailyMilk will increase by the milk amount entered above
  25. NEXT milking // milking will increase by 1 each loop
  26.  
  27. totalYield[cow]+=dailyMilk // Increasing the total milk given by the cow in the totalYield array over the 7 days.
  28. NEXT cow // cow will increase by 1 with each loop
  29.  
  30. NEXT day // day will increase by 1 with each loop.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement