A farmer records the milk production of a herb of cows. Every cow has a unique 3-digit identity code. Each cow can be milked twice a day, seven days a week. The volume of milk from each cow is recorded in litres correct to one decimal place (yield) every time the cow is milked. The size of the herd is fixed. At the end of the week the total and the average yield for each cow for that week is calculated.
The farmer identifies the cow that has produced the most milk that week The farmer also identifies any cows that have produced less than 12 litres of milk on four or more days that week.
A program is required to record the yield for each cow every time it is milked, calculate the total weekly volume of milk for the herd and the average yield per cow in a week. The program must also identify the cow with the best yield that week and identify any cows with a yield of less than 12 litres of milk for four or more days that week.
Write and test a program or programs for the farmer
• Your program or programs must include appropriate prompts for the entry of data
• Error messages and other output need to be set out clearly and understandably
• All variables, constants and other identifiers must have meaningful names
You will need to complete these three tasks. Each task must be fully tested.
TASK 1 - Record the yield
Write a program for TASK 1 to record the milk yields for a week The program records and stores the identity code number and the yield every time a cow is milked.
TASK 2 - Calculate the statistics
Using your recorded data from TASK 1 calculate and display the total weekly volume of milk for the herd to the nearest whole litre Calculate and display the average yield per cow in a week to the nearest whole litre.
TASK 3 - Identify the most productive cow and cows that are producing a low volume of milk
Extend TASK 2 to identify and display the identity code number and weekly yield of the cow that has produced the most milk. Also identify and display the identity code numbers of any cows with a yield of less than 12 litres of milk for four days or more in the week.
You are Here:
Home
> Forums
>< Study Help
>< Maths, science and technology academic help
>< Computer Science and ICT
|
Compsci 2018 pre-release paper watch
-
vinhle
- Follow
- 0 followers
- 2 badges
- Send a private message to vinhle
- Thread Starter
Offline2ReputationRep:- Follow
- 1
- 22-02-2018 16:35
-
vinhle
- Follow
- 0 followers
- 2 badges
- Send a private message to vinhle
- Thread Starter
Offline2ReputationRep:- Follow
- 2
- 22-02-2018 16:35
Please help
-
winterscoming
- Follow
- 12 followers
- 17 badges
- Send a private message to winterscoming
Online17ReputationRep:- Follow
- 3
- 22-02-2018 18:05
Could you be a bit more specific about which part of this you need help with? Have you read the whole brief, and the tasks, and understood what they're expecting you to do?
If you haven't started yet, look at each problem on its own, and start with the very simplest thing you could possibly do. If a problem is too big or complex, try solving just one part of that and break it down into tiny problems until those become solvable, or at the very least, they become problems which you can attempt, maybe google if you get stuck. Programming is all about "divide and conquer" problem-solving skills.
For example, do you know how to read a single input from the user?
If you can do that, do you know how to read many inputs from the user?
Have you thought about how to keep the user input or inputs in memory?
etc.
When you're given a task like this, you need to read it carefully. Read it multiple times if necessary and think about what the person using your program would expect it to do. Pay attention to detail - i.e. take in all the information about the scenario, and use that information to get a better idea of what you need to do for the tasks. If it helps, you could try to write down or draw some ideas out on paper to help you visualise the problem.
If you're stuck with a problem in code, It will be much easier for somebody to help you if you explain what you've actually done and tried so far, then show the code that you're having trouble with.
If you need to find out how to do something specific in Python, try the docs here https://docs.python.org/3/tutorial/index.html or just google.
TSR Isn't very good at handling code, so If you need to paste some example code and create a link, try using https://repl.it/languages/python3Last edited by winterscoming; 22-02-2018 at 18:09. -
vinhle
- Follow
- 0 followers
- 2 badges
- Send a private message to vinhle
- Thread Starter
Offline2ReputationRep:- Follow
- 4
- 23-02-2018 15:01
(Original post by winterscoming)
Could you be a bit more specific about which part of this you need help with? Have you read the whole brief, and the tasks, and understood what they're expecting you to do?
If you haven't started yet, look at each problem on its own, and start with the very simplest thing you could possibly do. If a problem is too big or complex, try solving just one part of that and break it down into tiny problems until those become solvable, or at the very least, they become problems which you can attempt, maybe google if you get stuck. Programming is all about "divide and conquer" problem-solving skills.
For example, do you know how to read a single input from the user?
If you can do that, do you know how to read many inputs from the user?
Have you thought about how to keep the user input or inputs in memory?
etc.
When you're given a task like this, you need to read it carefully. Read it multiple times if necessary and think about what the person using your program would expect it to do. Pay attention to detail - i.e. take in all the information about the scenario, and use that information to get a better idea of what you need to do for the tasks. If it helps, you could try to write down or draw some ideas out on paper to help you visualise the problem.
If you're stuck with a problem in code, It will be much easier for somebody to help you if you explain what you've actually done and tried so far, then show the code that you're having trouble with.
If you need to find out how to do something specific in Python, try the docs here https://docs.python.org/3/tutorial/index.html or just google.
TSR Isn't very good at handling code, so If you need to paste some example code and create a link, try using https://repl.it/languages/python3
#Task 3
#Identifying most productive and low producing cows
Total = []
LessMilk = ""
YieldOnDay = 0
Milking = 0
for j in range(Cows):
T = 0
Days = 0
Cow = Cow[j] #A cow chosen
for i in range(len(Cow)):
if Cow[i] == Cow:
T += Yield[i] #Incrementing the total for each cow
YieldOnDay += Yield[i]
Milking += 1
if Milking == 2: # 2 since checking for days, not milkings
if YieldOnDay < 12: #Checking if yield is less than 12 Days += 1 Milking = 0 YieldOnDay = 0 if Days > 3: #Low yield for 4 or more days
LessMilk = LessMilk + str(Cow[j]) + ", "
Total.append(T)
print(Total)
for i in range(Cows):
if Total[i] == max(Total):
print("Cow ", Cow[i], " has the highest yield of ", Total[i], " litres")
print("Cows which produced less than 12 litres of milk: " , LessMilk)
-
Computer Science and Artificial Intelligence
Loughborough University
-
University of Hull
-
University of Wales Trinity Saint David
-
Computer Aided Engineering (Foundation Entry)
Central Lancashire (UCLan)
-
Computer Networks & Systems Support
Bradford College
-
University of Suffolk
-
Adventure Sport & Coaching Science with Foundation Year
University of Derby
-
Coventry University
-
Food Science with Business with Industrial Training
University of Reading
-
Forensic Science with Criminology (Including Foundation Year)
University of South Wales
We have a brilliant team of more than 60 Support Team members looking after discussions on The Student Room, helping to make it a fun, safe and useful place to hang out.
- charco
- Mr M
- Changing Skies
- F1's Finest
- rayquaza17
- Notnek
- RDKGames
- davros
- Gingerbread101
- Kvothe the Arcane
- TeeEff
- The Empire Odyssey
- Protostar
- TheConfusedMedic
- nisha.sri
- claireestelle
- Doonesbury
- furryface12
- Amefish
- harryleavey
- Lemur14
- brainzistheword
- Rexar
- Sonechka
- TheAnxiousSloth
- EstelOfTheEyrie
- CoffeeAndPolitics
- an_atheist
- Labrador99
- EmilySarah00