Question

Write a Java program to convert volume in Gallons to liters. Gallons should be the input...

Write a Java program to convert volume in Gallons to liters. Gallons should be the input and liters in output

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.Scanner;

//TestBlock.java

public class TestBlock {

      

    public static void main(String[] args) {

       //Scanner Used to get the input from user

       Scanner scan = new Scanner(System.in);

       System.out.print("Enter the Volume in Gallons: ");

       double gal = scan.nextDouble();

      

       //Printing out the results

       System.out.println("Volume in Liters: "+gal*4.54609);

      

       scan.close();

    }  

}

Output:

<terminated> TestBlock [Java Application] C:\Prog Enter the volume in Gallons: 1 Volume in Liters: 4.54609

<terminated> TestBlock [Java Application] C:\Progra Enter the volume in Gallons: 0.22 Volume in Liters: 1.0001398000000001

Add a comment
Know the answer?
Add Answer to:
Write a Java program to convert volume in Gallons to liters. Gallons should be the input...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT