velikova_olya

distance

Jan 19th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. package SimpleCalcExams;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Distance {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9. int firstSpeed = Integer.parseInt(scanner.nextLine());
  10. int firstTime = Integer.parseInt(scanner.nextLine());
  11. int secondTime = Integer.parseInt(scanner.nextLine());
  12. int thirdTime = Integer.parseInt(scanner.nextLine());
  13.  
  14. double firstDistance = 0.0166667 * firstSpeed * firstTime;
  15. double secondDistance = 0.0166667 * (firstSpeed + firstSpeed * 0.1) * secondTime;
  16. double thirdDistance = 0.0166667 * ((firstSpeed + firstSpeed * 0.1) - (firstSpeed + firstSpeed * 0.1) * 0.05) * thirdTime;
  17.  
  18. double totalDistance = firstDistance + secondDistance + thirdDistance;
  19.  
  20. System.out.printf("%.2f", totalDistance);
  21.  
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment