Try This 1-2 Improving the Gallons-to-Liters Converter

GalToLitTable.java

You can use the for loop, the if statement, and code blocks to create an improved version of the gallons-to-liters converter that you developed in the first project. This new version will print a table of conversions, beginning with 1 gallon and ending at 100 gallons. After every 10 gallons, a blank line will be output. This is accomplished through the use of a variable called counter that counts the number of lines that have been output. Pay special attention to its use.

1. Create a new file called GalToLitTable.java.

2. Enter the following program into the file:

Image

3. Compile ...

Get Java, A Beginner's Guide, 5th Edition, 5th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.