# Converting liters to pints and gallons

Can anyone assist me ian writting a code for converting liters to pints and gallons,

I came up with this, however I can't seem to place it in a code.

U.S. gallon = 3.7854 liters. One liter = .264 U.S. gallon.
The formula for converting liters to U.S. gallons is:
Liters รท 3.7854 = U.S. gallons
Convert U.S. gallons to liters with the formula:
U.S. gallons x 3.785 = liters
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
Hi jahsexy18,

if the formula you have given is correct then it would be something like this in vb

Dim usg As Double, lit As Double
If MsgBox("Do you want to convert liters to gallon", vbYesNo) = vbYes Then
lit = InputBox("Enter quantity in liters: ", , 10)
usg = lit / 3.7854
MsgBox lit & " liters is equal to " & usg & " gallons"
Else
usg = InputBox("Enter quantity in gallons: ", , 10)
lit = usg * 3.785
MsgBox usg & " gallons is equal to " & lit & " liters"
End If

Rajesh
0

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Software ArchitectCommented:
It is a simple conversion, but, which programming language?

I don't see pints considerations in your formulas (I guess 1 pints = 1/8 gallon).
0
Commented:
0
Author Commented:
I am not sure I understand how this fit, can u please explain.  I have already created  auser interface, which has three labels

1. Input for liters

Also I have two buttons one to reset and one to compute

My problem is writtin the code to convert liters to pint and gallons.

u get liters to pint when u multiply liters by 2.1134
0
Software ArchitectCommented:
to convert liters to gallons and pints:

gallons = fix(liters / 3.7854)
pints = (liters / 3.7854 - gallons) * 8
0
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.