Turn on thread page Beta
    • Thread Starter
    Offline

    2
    ReputationRep:
    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.
    • Thread Starter
    Offline

    2
    ReputationRep:
    Please help
    Offline

    18
    ReputationRep:
    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
    • Thread Starter
    Offline

    2
    ReputationRep:
    (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
    I have done task 3 but could you see if there is anything that could be changed?
    #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)
 
 
 
Reply
Submit reply
Turn on thread page Beta
Updated: February 23, 2018
The home of Results and Clearing

1,349

people online now

1,567,000

students helped last year

University open days

  1. Bournemouth University
    Clearing Open Day Undergraduate
    Fri, 17 Aug '18
  2. University of Bolton
    Undergraduate Open Day Undergraduate
    Fri, 17 Aug '18
  3. Bishop Grosseteste University
    All Courses Undergraduate
    Fri, 17 Aug '18
Poll
Will you be tempted to trade up and get out of your firm offer on results day?

The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE

Write a reply...
Reply
Hide
Reputation gems: You get these gems as you gain rep from other members for making good contributions and giving helpful advice.