Skip to content

Instantly share code, notes, and snippets.

@pepet96
Created November 13, 2013 23:40
Show Gist options
  • Save pepet96/7458561 to your computer and use it in GitHub Desktop.
Save pepet96/7458561 to your computer and use it in GitHub Desktop.
MilesPerGallon
import java.util.Scanner;
class MilesPerGallon {
public static void main(String[] args){
Scanner input = new Scanner(System.in);
int imiles, fmiles, gallons, mpg;
imiles = 0;
while(imiles>=0){
System.out.println("Please introduce initial miles: ");
imiles = input.nextInt();
System.out.println("Please introduce final miles: ");
fmiles = input.nextInt();
System.out.println("Please introduce gallons ");
gallons = input.nextInt();
mpg = (imiles + fmiles)/gallons;
System.out.println("Miles Per Gallon: " + mpg);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment