Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- INPUT noCows // Input number of cows in a herd
- cowIds = [1:noCows] // Array to store IDs, the length will be dependent on the noCows input.
- totalYield = [1:noCows] // Array to store the total milk from each cow over the 7 days.
- idLength = 3 // Constant used for validation of cow ID (the ID length should be 3 numbers)
- FOR day = 1 to 7 // Loop for 7 days
- FOR cow = 1 to noCows // Loop for number of cows
- IF day == 1 // If day 1 then the cow ID should be entered,
- id=0 // Initialising id to 0 (not 3 digits long)
- WHILE length(id) != idLength // Checks if the id length is 3 digits
- OUTPUT "Enter Cow ID"
- INPUT id // Prompt to enter ID at the beginning as the length is currently 1(id=0)
- END WHILE
- cowIds[cow] = id //Once the ID entered is 3 digits long then it will be added to the cowsIds array.
- totalYield[cow]=0
- END IF
- dailyMilk=0 // dailyMilk set to 0 before loop below
- FOR milking = 1 to 2 // loop for 2 milk readings a day
- OUTPUT "Milk Reading "+milking
- INPUT milkAmount
- dailyMilk+=milkAmount // dailyMilk will increase by the milk amount entered above
- NEXT milking // milking will increase by 1 each loop
- totalYield[cow]+=dailyMilk // Increasing the total milk given by the cow in the totalYield array over the 7 days.
- NEXT cow // cow will increase by 1 with each loop
- NEXT day // day will increase by 1 with each loop.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement