Need help writing equation for CS115 class

For students who are taking a programming course, may be restricted in what they can use, or have other unusual limitations on solving their task.

Need help writing equation for CS115 class

I need help writing an equation that is taking the input from the user, three different sizes of paint containers in 4 different colors and converting it to the smallest unit, which would be pints. Then output the highest number of gallons sold.

for example:
input would be:
Red: 1 gallon, 2 quarts, and 1 pint
Green: 2 gallons, 1 quart, and 1 pint
Yellow: 1 gallon, 2 quart, and 0 pints
Blue: 0 gallons, 1 quart, and 1 pint

the total paint sold would need to output it as a sale to show that it was 5 gallons, 3 quarts, and 1 pint
basically the highest number of gallons with the highest remaining quarts and highest remaining pints

I have been trying for three days now to get this equation right and have to have it done by midnight.
Last edited by micseydel on Wed Sep 21, 2016 11:13 pm, edited 1 time in total.
Reason: Initial post lock.
mdinsmore0004

Posts: 5
Joined: Wed Sep 21, 2016 11:03 pm

Re: Need help writing equation for CS115 class

What have you tried? We're happy to help, but we need to see what you've done so far.
Due to the reasons discussed here we will be moving to python-forum.io on October 1, 2016.

This forum will be locked down and no one will be able to post/edit/create threads, etc. here from thereafter. Please create an account at the new site to continue discussion.

micseydel

Posts: 3000
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA

Re: Need help writing equation for CS115 class

I suspect I've found your professor's site for the course. You should probably review her "how to ask questions" link as well.
Due to the reasons discussed here we will be moving to python-forum.io on October 1, 2016.

This forum will be locked down and no one will be able to post/edit/create threads, etc. here from thereafter. Please create an account at the new site to continue discussion.

micseydel

Posts: 3000
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA

Re: Need help writing equation for CS115 class

The program is kind long itself this is just the equation without the inputs being received for the user

Code: Select all
`just_pints = total_pints_sold + (total_gallons_sold * 8) \             + (total_quarts_sold * 2)#calculate the total amount of the start amount of pintsstart_just_pints = 430 - just_pints# calculate the total number of quartsjust_quarts = (start_just_pints // 2)# calculate the total number of just gallonsjust_gallons = start_just_pints % 8`

i asked my professor and the only hint that he had given me was because i said something about the program needing to display just gallons and he recommended to convert it into just pints
mdinsmore0004

Posts: 5
Joined: Wed Sep 21, 2016 11:03 pm

Re: Need help writing equation for CS115 class

Code: Select all
`#calculate the total number of gallons soldtotal_gallons_sold = red_gallons_sold + green_gallons_sold + yellow_gallons_sold \               + blue_gallons_sold# calculate the total number of quarts soldtotal_quarts_sold = red_quarts_sold + green_quarts_sold + yellow_quarts_sold \              + blue_quarts_sold# calculate the total number of pints soldtotal_pints_sold = red_pints_sold + green_pints_sold + yellow_pints_sold \             + blue_pints_sold`

that would probably be essential too for defining my variables from the user
mdinsmore0004

Posts: 5
Joined: Wed Sep 21, 2016 11:03 pm

Re: Need help writing equation for CS115 class

if I'm not mistaken, since you can have 10 gallons, quarts, and pints of red, green, yellow, and blue paint the total for just pints would be 10*8 = 80 * 3 = 160 would be the just pints from gallons since there are 8 pints in a gallon and then 10*2 = 20 * 3 = 60 would be the just pints from quarts since there are 2 pints in a quart. totaling 430 total just pints to work with
mdinsmore0004

Posts: 5
Joined: Wed Sep 21, 2016 11:03 pm

Re: Need help writing equation for CS115 class

Still looking for some help if anyone is willing
mdinsmore0004

Posts: 5
Joined: Wed Sep 21, 2016 11:03 pm

Re: Need help writing equation for CS115 class

You need to really refine your question. Post a runnable snippet of code with no input, just hard-coded values that reproduce your problem, and say what the expected and actual output is for that runnable snippet of code.
Due to the reasons discussed here we will be moving to python-forum.io on October 1, 2016.

This forum will be locked down and no one will be able to post/edit/create threads, etc. here from thereafter. Please create an account at the new site to continue discussion.

micseydel

Posts: 3000
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA