daily pastebin goal
56%
SHARE
TWEET

Speed Calculator 2 (Time [m], Distance [m])

TomaszSoroka Feb 17th, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Locale;
  2. import java.util.Scanner;
  3.  
  4.     public class SpeedCalculator2 {
  5.         public static void main(String[] args) {
  6.             //Create the Scanner
  7.             Scanner scan = new Scanner(System.in).useLocale(Locale.ENGLISH);
  8.             //enable to import from the user
  9.             //Scanner(System.in).useLocale(Locale.ENGLISH) allow to use . instead of ,
  10.             System.out.println("Speed Calculator (Time [m], Distance [m])");
  11.             System.out.println("-----------------------------------------");
  12.             System.out.println("Enter the distance in meters: ");
  13.             double distanceInMeters = scan.nextDouble();
  14.             System.out.println("Enter the time in minutes");
  15.             double timeInSeconds = scan.nextDouble();
  16.  
  17.             System.out.println("Your distance is: " + distanceInMeters + " meters");
  18.             System.out.println("Your time is: " + timeInSeconds + " minutes");
  19.  
  20.             double speedMs = distanceInMeters/timeInSeconds;
  21.             final double MS_TO_KMH_UNIT = 0.060;
  22.             double speedKmh = speedMs * MS_TO_KMH_UNIT;
  23.             System.out.println("Your speed in km/h: ");
  24.             System.out.println(speedKmh);
  25.         }
  26.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top