Advertisement
Guest User

Untitled

a guest
Oct 8th, 2015
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. import java.util.Scanner; //Importing Utility Scanner
  2.  
  3.  
  4. public class Assignment1
  5. {
  6. static Scanner sc=new Scanner(System.in); //Scanner
  7. static final double CONVERT_MILES=1.609; //Constant Value
  8. public static void main(String[]args) //Always have a main method
  9. {System.out.print("Enter number of miles: ");//command line prints Enter number miles here
  10. double numMile=sc.nextDouble();//Scanner scans for the users inout
  11. double numMileKilo=numMile*CONVERT_MILES;//formula for converting miles to km
  12. System.out.printf("%.3f miles convert to %.3f kilometers", numMile, numMileKilo);
  13.  
  14. }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement