Advertisement
YavorGrancharov

Distance

Feb 26th, 2017
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.94 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Distance {
  4.     public static void main(String[] args) {
  5.         Scanner console = new Scanner(System.in);
  6.         int firstSpeed = Integer.parseInt(console.nextLine());
  7.         int firstTime = Integer.parseInt(console.nextLine());
  8.         int secondTime = Integer.parseInt(console.nextLine());
  9.         int thirdTime = Integer.parseInt(console.nextLine());
  10.  
  11.         double first = firstTime / 60.0;
  12.         double second = secondTime / 60.0;
  13.         double third = thirdTime / 60.0;
  14.  
  15.         double secondSpeed = firstSpeed + (firstSpeed * 0.10);
  16.         double thirdSpeed = secondSpeed - (secondSpeed * 0.05);
  17.  
  18.         double firstDistance = firstSpeed * first;
  19.         double secondDistance = secondSpeed * second;
  20.         double thirdDistance = thirdSpeed * third;
  21.  
  22.         double distance = firstDistance + secondDistance + thirdDistance;
  23.  
  24.         System.out.printf("%.2f", distance);
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement