fork download
  1. import java.util.Scanner;
  2.  
  3. class MileConversionsInteractive
  4. {
  5. public static void main(String[] args)
  6. {
  7. //Number of miles
  8. int miles;
  9.  
  10. //Named Constants
  11. final int INCHES_TO_MILES = 63360;
  12. final int FEET_TO_MILES = 5280;
  13. final int YARDS_IN_MILES = 1760;
  14.  
  15. //Interactive
  16. Scanner scanner = new Scanner(System.in);
  17.  
  18. //Input
  19. System.out.print("Input how many miles: ");
  20. miles = scanner.nextInt();
  21.  
  22. //Conversions
  23. int totalYards = miles * YARDS_IN_MILES;
  24. int totalFeet = miles * FEET_TO_MILES;
  25. int totalInches = miles * INCHES_TO_MILES;
  26.  
  27. //Explanatory Text
  28. System.out.println("There is " + miles + " mile(s), which is equalivent to:");
  29. System.out.println(totalYards + " yards");
  30. System.out.println(totalFeet + " feet");
  31. System.out.println(totalInches + " inches");
  32.  
  33. }
  34. }
Success #stdin #stdout 0.18s 60732KB
stdin
2


stdout
Input how many miles: There is 2 mile(s), which is equalivent to:
3520 yards
10560 feet
126720 inches