To convert Gallon to liter we are using a formula “liter = gallon * 3.7854118“.
Java Program to covert Gallon to liter
import java.util.*; import java.io.*; public class GaltoLitr { public static void main (String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.print("How many Gallon do you want to enter "); int gallons = Integer.parseInt(br.readLine()); double liters = gallons * 3.7854118; System.out.println("The Value in Litres is " + liters); } }
output:-