Example of what you might be trying to do (details below)
import java.util.Scanner;
public class GasMileage
{
public static void main(String[ ] args)
{
Scanner keyboard = new Scanner(System.in);
boolean stillInLoop = true;
while (stillInLoop)
{
System.out.print("How many miles were driven? ");
int miles;
miles = keyboard.nextInt();
System.out.print("How many gallons were used? ");
int gallons;
gallons = keyboard.nextInt();
int mpg;
mpg = miles / gallons;
System.out.println(" The Miles-Per-Gallon used in this trip are " + mpg);
stillInLoop = false;
}
}
}
A few tips:
1) If you use a while condition, you are running that loop until something no longer remains true, in which case java will automatically exit the loop. These conditions are either true or false (boolean). I notice that you didn't specify what you'd like in your while loop. It would really help if you could provide us with more information as to what else you're trying to do.
2)
Be sure to include the space in between your question and quotation marks in your print statements or your output will get bunched up like this:
Bad practice:
System.out.print("How many miles were driven?");
Output: How many gallons were used?5
Good practice:
System.out.print("How many miles were driven? ");
Output: How many gallons were used? 5
Notice the spacing.
3)
The code I gave you might seem vague but it's because I didn't have a condition to work with specifically. Figure out which section(s) of your code need to continue running until a certain condition has been met. I called the boolean variable "stillInLoop" in my example but generally this is extremely unhelpful to anyone reading your code and you'd probably be better off naming it something more helpful.
Hopefully this helped out a bit. Good luck!