?
Solved

Converting liters to pints and gallons

Posted on 2004-11-17
8
Medium Priority
?
15,564 Views
Last Modified: 2012-06-27
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
0
Comment
Question by:jahsexy18
5 Comments
 
LVL 24

Accepted Solution

by:
R_Rajesh earned 1000 total points
ID: 12603815
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
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 12603831
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
 
LVL 48

Expert Comment

by:Mikal613
ID: 12603908
0
 

Author Comment

by:jahsexy18
ID: 12604288
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
2. read only for pints
3. read only for gallons

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
 
LVL 55

Assisted Solution

by:Jaime Olivares
Jaime Olivares earned 1000 total points
ID: 12604367
to convert liters to gallons and pints:

gallons = fix(liters / 3.7854)
pints = (liters / 3.7854 - gallons) * 8
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Starting up a Project

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question