473,385 Members | 1,341 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

My pratice controlled assesment and i have trouble with the boundaries

import math
#program to work out the amount of ingredients needed in boxes for the user for lemon drizzle cake and cupcakes
amocc=input("Hello, how many chocolate cupcakes do you want?")
amold=input("How many lemon drizzle cupcakes do you want?")
##"amocc" is short for "amount of chocolate cupcakes"##
##"amold" is short for "amount of lemon drizzle"##

#Working the amount of ingredients needed for single cupcake#
ccpf= int(amocc) * (12)
ccs= int(amocc) * (14)
ccub= int(amocc) * (4)
ccfre= math.ceil(int(amocc) * (0.1))
ccfre2= round(int(amocc) * (0.1),2)
#As you can only have full eggs round up to highest int using math import#

#Amount for a single lemon drizzle#
ldpf=float(amold) * (240)
lds=float(amold) * (300)
ldub=float(amold) * (80)
ldfre= math.ceil(float(amold) * (4.5))
ldfre2=round(int(amold)*(4.5),2)

##Amount of lemon drizzle printed##
print("\n")
print("For the",amold,"lemon drizzle cake you will need ", ldpf,"g of plain flour,")
print(lds,"g of sugar,")
print(ldub,"g of unsalted butter,")
print("And",ldfre,"eggs;how ever you will only need to use ",ldfre2,"parts of the eggs")
print("\n")

##Amount for cupcakes printed##
print("For the ",amocc,"chocolate cupcakes you will need ", ccpf,"g of plain flour,")
print(ccs,"g of sugar,")
print(ccub,"g of unsalted butter,")
print("And",ccfre,"eggs;how ever you will only need to use ",ccfre2,"number/parts of the eggs")
print("\n")

##Amount of total ingriedents##
plainflour=float(ldpf) + float(ccpf)
sugar=float(ccs) + float(lds)
unsaltedbutter=float(ccub) + float(ldub)
eggs=float(ldfre) + float(ccfre)

#Starting amount of bags#
largepf=0
mediumpf=0
smallpf=0
larges=0
mediums=0
smalls=0
largeub=0
mediumub=0
smallub=0
largefre=0
mediumfre=0
smallfre=0

##Calculating the amount of bags needed##

#Bags for the plain flour#
while(750<=(plainflour)):
largepf=(largepf) + 1
plainflour=(plainflour)-750
else:750>=(plainflour)
if (0<(plainflour)<=250):
smallpf=(smallpf) + 1
if (250<(plainflour)<=500):
mediumpf=(mediumpf) + 1
if (500<(plainflour)>=750):
largepf=(largepf) + 1

#Bags for the sugar#
while(600<=(sugar)):
larges=(larges) + 1
sugar=(sugar)-600
else: 600>(sugar)
if (0<(sugar)<=200):
smalls=(smalls) + 1
if (200<(sugar)<=400):
mediums=(mediums) + 1
if (400<(sugar)>600):
larges=(larges) + 1

#Bags for the unsaltedbutter#
while(500<=(unsaltedbutter)):
largeub=(largeub) + 1
unsaltedbutter=(unsaltedbutter)-500
else: 750>(unsaltedbutter)
if (0<(unsaltedbutter)<=125):
smallub=(smallub) + 1
if (125<(unsaltedbutter)<=250):
mediumub=(mediumub) + 1
if (250<(unsaltedbutter)>=500):
largeub=(largeub) + 1

#Boxes for the freerange eggs#
while(12<(eggs)):
largefre=(largefre) + 1
eggs=(eggs)-12
else: 12>(eggs)
if (0<(eggs)<=6):
smallfre=(smallfre) + 1
if (6<(eggs)<=10):
mediumfre=(mediumfre) + 1
if (10<(eggs)>=12):
largefre=(largefre) + 1

##Printing and displaying amounts##

#Displaying the quantity of eggs#
print("You will need:""\n" ,largefre,"large boxes of eggs (12 eggs)")
print(mediumfre,"medium boxes of eggs (10eggs),")
print("and",smallfre,"small boxes of eggs (6 eggs)")
print("\n")

#Displaying the quantity of sugar#
print(larges,"large bags of sugar (600grams),")
print(mediums,"medium bags of sugar (400grams),")
print("And",smalls,"small bags of sugar (200grams)")
print("\n")

#Displaying the quantity of unsalted butter#
print(largeub,"large bags of unsaltedbutter (500grams),")
print(mediumub,"medium bags of unsaltedbutter (250grams),")
print("And",smallub,"small bags of unsaltedbutter (125grams)")
print("\n")

#Displaying the quantity of plainflour#
print(largepf,"large bags of plainflour (750grams),")
print(mediumpf,"medium bags of plainflour (500grams),")
print("And",smallpf,"small bags of plainflour (250grams)")

This is my code and when I input in 10 cupcakes and 1 lemon drizzle cake there is no value for sugar, it displays 0 of everything, please can someone see what was wrong
Jul 20 '16 #1
1 1058
dwblas
626 Expert 512MB
There is no way to help without knowing the results of any debugging that you have done. Did you print sugar under the while() and does it have an initial value? If not, do so and post what prints.
Jul 20 '16 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: weston | last post by:
So, I'm attempting to code an expanding tree menu, based off of unordered lists containing unordered lists. I'm also trying to do it in such a way that none of the javascript has to go inline with...
8
by: Pegboy | last post by:
I am having trouble with malloc() again for a PC app I am developing. The method of the suspicious line of code seems to be Ok on a embedded platform, but not with the PC platform. The embedded...
3
by: Tobias[br] | last post by:
hi there people... i´m developing an application where i need 190 input text, in 8 diferent forms.. anyone can tell me the best pratice to save the the data while edit the others forms?...
3
by: steve | last post by:
Hello, I am having a problem with an index controlled partitioned table. I was altering a table using SQL. I was trying to add a partition to a table to change it from index controlled to...
1
by: Mike Green | last post by:
Hi all Please could someone point me in the right direction? I am looking for some Java code to let the user control a text box on a web site. This is very similar to the standard IFRAME tag. I...
6
by: Gary Bond | last post by:
Hi All, Being a bit of a newbie with regex, I am confused when using word boundaries. For instance, I want to replace all the stand alone '.5k' that occur in an input string, with 500. In other...
3
by: cbradio | last post by:
Hi, I am having trouble developing a form in a restricted environment. My sample code is found below my message (sorry I don't have a URL). Basically, without a doctype, the form displays properly...
2
by: OSI Mik | last post by:
Hello, I try to make a user interface for a DB in VB.DOT 2005 with SQL server. I use auto generate Textbox and datagridview (with BindingSource, TableAdapter...) with manual add of ComboBox and I...
2
by: Vicky26 | last post by:
Hi! I am new to Flash and I am having trouble getting a dyamic text box to be controlled by a checkbox. Here is the Actionscript that does not work: on(click){ if(this.selected)==true){...
4
by: Phil Davis | last post by:
Hi I'm struggling to find an elegant way of determining whether the date from a record falls within a number of date boundaries ranges. For example in a separate (date boundaries) table I code the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.