Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Locale;
- import java.util.Scanner;
- public class SpeedCalculator2 {
- public static void main(String[] args) {
- //Create the Scanner
- Scanner scan = new Scanner(System.in).useLocale(Locale.ENGLISH);
- //enable to import from the user
- //Scanner(System.in).useLocale(Locale.ENGLISH) allow to use . instead of ,
- System.out.println("Speed Calculator (Time [m], Distance [m])");
- System.out.println("-----------------------------------------");
- System.out.println("Enter the distance in meters: ");
- double distanceInMeters = scan.nextDouble();
- System.out.println("Enter the time in minutes");
- double timeInSeconds = scan.nextDouble();
- System.out.println("Your distance is: " + distanceInMeters + " meters");
- System.out.println("Your time is: " + timeInSeconds + " minutes");
- double speedMs = distanceInMeters/timeInSeconds;
- final double MS_TO_KMH_UNIT = 0.060;
- double speedKmh = speedMs * MS_TO_KMH_UNIT;
- System.out.println("Your speed in km/h: ");
- System.out.println(speedKmh);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement