The manager of a building materials delivery service needs a program to check the contents and weight
of sacks to ensure that correct orders are made up for delivery. A price for the order will be calculated.
Write and test a program for the manager.
• Your program must include appropriate prompts for the entry of data.
• Error messages and other output need to be set out clearly.
• 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 – Check the contents and weight of a single sack
Each sack must obey the following rules to be accepted:
• contain cement, gravel or sand, with a letter on the side for easy identification
o C - cement
o G - gravel
o S - sand
• sand or gravel must weigh over 49.9 and under 50.1 kilograms
• cement must weigh over 24.9 and under 25.1 kilograms
Input and store the weight and contents for one sack. The contents must be checked and an incorrect
sack rejected. The weight must be validated on entry and an overweight or underweight sack rejected.
Output the contents and weight of an accepted sack. If a sack is rejected, output the reason(s).
What I have tried:
Content = str(input("What is the content?"))
Content_sub1 = "C"
if Content_sub1 in Content :
Weight_ofc = float(input("What is the weight of the sack"))
if Weight_ofc < 49.9 :
print("The weight of the sac is too low")
elif Weight_ofc > 55 :
print("The weight of the sac is too high")
else: print(Content , Weight_ofc )
else : print("the sack is invalid")
Content_sub2 = "G"
if Content_sub2 in Content :
Weight_ofg = float(input("What is the weight of the sack"))
if Weight_ofg < 49.9 :
print("The weight of the sac is too low")
elif Weight_ofg > 55 :
print("The weight of the sac is too high")
else: print(Content , Weight_ofg )
else : print("the sack is invalid")
Conent_sub3 ="S"
if Conent_sub3 in Content :
Weight_ofs = float(input("What is the weight of the sack"))
if Weight_ofs < 24.9 :
print("The weight of the sac is too low")
elif Weight_ofs > 25.1 :
print("The weight of the sac is too high")
else: print(Content , Weight_ofs)
else : print("the sack is invalid")