• Home
  • A level
    • Biology
    • Chemistry
    • Physics
    • Mathematics
    • Computer Science
    • Business studies
  • O levels
    • Physics
    • Computer Science
    • Islamiat
    • Pak Studies
  • Past papers
    • O level Past Papers (2020 Updated)
    • A level Past Papers
    • IGCSE Past Papers
  • E Books
  • Topicals
    • O level Topical Past papers
    • A Level Topical Past Papers
    • IGCSE Topical Past Papers
  • Contact us
Search
Gcecompilation
Home O level Computer science O level Computer science Pre release Material 2018
  • O level
  • Computer science

O level Computer science Pre release Material 2018

15
O level computer sciecne Pre release material solution

Pre release Material 2018

Update: Oct/Nov 2018 Pre release Material uploaded, click here

In preparation for the examination candidates should attempt the following practical tasks by writing and testing a program or programs.
A farmer records the milk production of a herd 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 the milk from each cow is recorded in liters 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 the 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 liters 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 cow with a yield of less than 12 liters of milk for four or more days that week.

Write and test a program or programs for the farmer.Your program of programs must include the 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 theidentify 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 nearest while liter. Calculate and display the average yield per cow in a week to the nearest whole liter.ico calendar

TASK 3 – Identify the most productive 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 liters of milk for four days or more in the week.

Download PDF

Visual Basic (Forms base) Solution

Task1 

Dim nofcows, cowid As Integer
Dim morning, evening, weektotalcow As Single
nofcows = InputBox("How many cows in a herd ? ")
Dim cowids(0 To nofcows) As Integer
Dim milkstore(0 To nofcows) As Single
For cows = 1 To nofcows
	cowid = InputBox(" Enter cow ID ")
	While cowid < 100 Or cowid > 999
		MsgBox(" You have entred the wrong ID. Enter 3 number code. ")
		cowid = InputBox(" Enter cow ID ")
		End While
		cowids(cows) = cowid
	Next
	For cows = 1 To nofcows
		MsgBox(" Enter Milk Yield for cow ID no : " & cowids(cows))
		For days = 1 To 7
			MsgBox(" For day : " & days)
			morning = InputBox(" Morning Yield in liters for cow ")
			evening = InputBox(" Evening Yield in liters for cow ")
			weektotalcow = weektotalcow + morning + evening
		Next
		milkstore(cows) = weektotalcow
	Next


Task 2

Dim total_yield, avg_yield As Single
For cows = 1 To nofcows
	avg_yield = milkstore(cows) / nofcows
	MsgBox(" The average Yield of cow ID no " & cowids(cows) & " is : " &
	Math.Round(avg_yield))
	total_yield = total_yield + milkstore(cows)
Next
MsgBox(" The total weekly volume of milk for the herd : " &
Math.Round(total_yield))


Task 3


Dim highest_yeild As Single
Dim highest_ID As Integer
highest_yeild = 0
For cows = 1 To nofcows
	If milkstore(cows) > highest_yeild Then
		highest_yeild = milkstore(cows)
		highest_ID = cowids(cows)
		End IfPre Release Material CS 2210 O Levels Summers 2018
		A Project Of csmeasy.com
	Next
	MsgBox(" The Cow ID no : " & highest_ID & " has produced the highest yeild " &
	highest_yeild)
	For cows = 1 To nofcows
		If milkstore(cows) < 12.0 Then
			MsgBox(" The cow ID no " & cowids(cows) & " has produced less then 12
			Liters In a week")
		End If
	Next
End Sub
End Class


Credits to : Engr. Bandeshah for the Visual Basic Solution

Python Solution

Task 1


#Recording the yield
Cow = []
Yield = []

Cows = int(input("How many cows are in the herd?  "))
Day = 0     #to configure the milking
for i in range(14):
    if i%2 == 1:
        Milking = "Second"
    else:
        Milking = "First"
        Day += 1
    print("Day ", Day, "; ", Milking, " milking")
    for i in range(Cows):
        while True:
            Code = int(input("Enter code: "))
            if Code > 999 or Code < 100:
                print("Enter a 3-digit code please")
            else:
                Cow.append(Code)
                break
        Y = float(input("Enter volume of milk in litres: "))    #A range check for yield can be added 
        Yield.append(Y)

Task 2


#Finding the Total and Average
Total = 0
for i in range(len(Yield)):
    Total += Yield[i]
Average = Total/Cows

round(Total, 0)
round(Average, 0)

print("Total weekly volume of milk: ", int(Total), " litres")
print("Average yield per cow: ", int(Average), " litres")

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)

 

Update: Oct/Nov 2018 Pre release Material uploaded, click here

  • TAGS
  • 2018
  • Computer science
  • o level
  • Pre release Material
Previous articleO level Islamiyat Past Papers
Next articleCambridge IGCSE Computer science Coursebook PDF | Free Download
Moiz khan
Hello, I am a Web developer and blogger, currently a UETian, I want to compile all the best O and A level resources at one place for the ease of students.

RELATED ARTICLES

worksheets

GCSE Mathematics Revision Worksheets [PDF]

Mathematics April 14, 2020
O/A level Equivalence calulator

O Level Equivalence Calculator

O level August 26, 2019
o level physics atp

O Level Physics ATP Notes [PDF]

O level July 31, 2019

15 COMMENTS

  1. O level Computer science Pre release material Oct/Nov 2017 Solution February 4, 2018 at 3:57 pm

    […] O Level Computer science Pre release matreial solutuion for May/June 2018 has also been uploaded Cli… […]

    Reply
  2. Akmal February 26, 2018 at 2:14 am

    Can i get the answer in psedocode please…

    Reply
  3. XYZ March 2, 2018 at 2:23 pm

    Doesn’t solve the unique ID problem

    Reply
  4. Zaheer March 4, 2018 at 9:09 am

    Can i get the answer in psedocode please…

    Reply
    • Shayan May 15, 2018 at 5:25 pm

      For pre-release material in PESEDUCODE contact me at shayanriazahmed123@gmail.com or 03332622989

      Reply
  5. Ashnah Khalid Khan March 8, 2018 at 5:07 pm

    The task 3 specifically states “identify and display the identity code numbers of any cows with a yield of less than 12 liters of milk **for four days or more** in the week”. Your variable “milkstore” stores the total weekly volume of milk yield from each cow so how can this requirement of the task be satisfied by this statement of your program: “If milkstore(cows) < 12.0 ….."
    ????

    Reply
  6. Gladiator March 12, 2018 at 8:10 am

    avg_yield = milkstore(cows) / nofcows

    This statement seems to me incorrect. Here we are dividing 1 cow yield by noofcows which seems incorrect. It should be either noofdays(7) or we have complete total of milk yield for all the cows. These are my suggestions.

    Reply
  7. Peter Bartels March 29, 2018 at 8:06 am

    It says the size of the herd if fixed, still your asking to input the size of the herd (I think this is a constant candidate). Furthermore, the three digit check is wrong, what if the three digit is 000 or 099?

    Reply
    • uzair ahmed April 14, 2018 at 2:27 pm

      three digit starts from 100

      Reply
    • ham May 15, 2018 at 6:50 pm

      in computer 0s are count as ‘off’ , three digit ; would mean that 1000

      Reply
  8. Ali April 24, 2018 at 8:31 am

    Anyone needs Visual Basic Console Application Solution for IGCSE / O- levels Pre Release material June 2018
    Contact me at my email
    alidoqman1@gmail.com

    Reply
  9. remu May 5, 2018 at 12:45 am

    I TOO NEEDED THE SOLUTION IN PSEUDO CODES

    Reply
  10. Affan May 15, 2018 at 2:46 pm

    Good Job but one point is not considered here which is very important for marks. “for 4 or more days”
    there should be counter for those days.

    Reply
  11. IDGAF May 16, 2018 at 4:13 pm

    Are there answers for IGCSE?

    Reply
  12. Moiz khan September 24, 2018 at 6:07 pm

    Oct/nov 2018 Pre release : https://gcecompilation.com/o-level-computer-science-pre-release-material-2018-oct-nov-solution/

    Reply

LEAVE A REPLY Cancel reply

Please enter your comment!
Please enter your name here
You have entered an incorrect email address!
Please enter your email address here

O/A level resources
ABOUT US
Gcecompilation.com is an initiative taken with the aim to compile the best O & A Level Notes, Revision Guides, Tips, Videos and Websites from all around the world at one place.
Contact us: admin@gcecompilation.com
FOLLOW US
© Copyright Gcecompilation.com || All rights reserved
Edit with Live CSS
Save
Write CSS OR LESS and hit save. CTRL + SPACE for auto-complete.