Question: Please rewrite the following program so that it takes gallons as user input and prints out the litters. /* This program displays a conversion table

Please rewrite the following program so that it takes gallons as user input and prints out the litters.

/* This program displays a conversion table of gallons to liters. Call this program "GalToLitTable.java". */ class GalToLitTable { public static void main(String[] args) { double gallons, liters; int counter; counter = 0; for (gallons = 1; gallons <= 100; gallons++) { liters = gallons * 3.7854; // convert to liters System.out.println(gallons + " gallons is " + liters + " liters."); counter++; // every 10th line, print a blank line if (counter == 10) { System.out.println(); counter = 0; // reset the line counter } } } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!