I am quite new at JAVA however, I tried what you posted and it works for me - trying using this code
class Example{
public static void main(
String [] args){
double gallons;
double liters;
int counter;
counter = 0;
for (gallons = 1; gallons <=20; gallons++){
liters = gallons * 3.75;
System.out.println("We have " + liters + " liters");
counter++;
if (counter == 5){
System.out.println();
counter = 0;
}
}
}
}