Advertisement
yovkovbpfps

Exam 1-2 December 2018 MountainRun

Apr 24th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class MountainRun {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. double seconds = Double.parseDouble(scanner.nextLine());
  8. double meters = Double.parseDouble(scanner.nextLine());
  9. double timeInSecondsForOneMeter = Double.parseDouble(scanner.nextLine());
  10.  
  11. double inclide = meters * timeInSecondsForOneMeter;
  12. double inclide2 = Math.floor(meters / 50) * 30;
  13. double timeNeeded = inclide + inclide2;
  14.  
  15. double ostatuk = timeNeeded - seconds;
  16.  
  17. if (seconds > timeNeeded){
  18. System.out.printf("Yes! The new record is %.2f seconds.",timeNeeded);
  19. }else{
  20. System.out.printf("No! He was %.2f seconds slower.",ostatuk );
  21. }
  22.  
  23.  
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement