Created
November 13, 2013 23:40
-
-
Save pepet96/7458561 to your computer and use it in GitHub Desktop.
MilesPerGallon
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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