Advertisement
desislava_topuzakova

02. Skeleton

Jun 10th, 2023
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Task2 {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6. //1. входни данни
  7. int minutes = Integer.parseInt(scanner.nextLine()); //минути за подобряване -> 2 min
  8. int seconds = Integer.parseInt(scanner.nextLine()); //секунди за подобряване -> 12 sec
  9. double length = Double.parseDouble(scanner.nextLine());
  10. int secondsPer100Meters = Integer.parseInt(scanner.nextLine());
  11.  
  12. //2. времето, което трябва да подобрим в секунди
  13. int timeRecordInSeconds = minutes * 60 + seconds; //2 min 12 sec -> 132 sec
  14.  
  15. //3. време за забързваме
  16. double countSpeed = length / 120; //колко пъти се забързваме
  17. double timeSpeed = countSpeed * 2.5; //времето на забързваме
  18.  
  19. //общо време, за което преминава през разстоянието
  20. double totalTimeInSeconds = (length / 100) * secondsPer100Meters - timeSpeed;
  21.  
  22. //проверка дали времето подобрява рекорда
  23. if (totalTimeInSeconds <= timeRecordInSeconds) {
  24. System.out.println("Marin Bangiev won an Olympic quota!");
  25. System.out.printf("His time is %.3f.", totalTimeInSeconds);
  26. } else {
  27. //timeRecordInsSeconds < totalTimeInSeconds
  28. double needSeconds = totalTimeInSeconds - timeRecordInSeconds;
  29. System.out.printf("No, Marin failed! He was %.3f second slower.", needSeconds);
  30. }
  31.  
  32. }
  33. }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement