Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //package bpa;
- import java.util.Scanner;
- /**
- *
- * @author Devin Mitchell
- */
- public class SpeedingHighway {
- private static int l; //speed limit
- private static int s; //speed driving
- private static int d; //distance
- public static void main(String args[]) {
- Scanner sc = new Scanner(System.in);
- l = sc.nextInt(); //initiating speed limit
- s = sc.nextInt(); //initiating driving speed
- d = sc.nextInt(); //initiating distance
- int time = 0;
- if ( l < 0 || s < 0 || d < 0) { // checks if 3 positive integers were entered
- System.out.println("You must enter 3 positive numbers!");
- return;
- }
- if (s >= l) {
- time = (int)(60 * ((double) d / l)) - (int)(60 * ((double) d / s)); // calculates the time saved
- System.out.println();
- System.out.println(time + " minutes saved.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement