Advertisement
Edzhevit

Untitled

Sep 18th, 2018
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. package OldExams;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class SwimmingRecord {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8. double recordSec = Double.parseDouble(scanner.nextLine());
  9. double distanceMet = Double.parseDouble(scanner.nextLine());
  10. double secsInOneMet = Double.parseDouble(scanner.nextLine());
  11.  
  12. double swimDistance = distanceMet * secsInOneMet;
  13. double slowTime = Math.floor((distanceMet / 15)) * 12.5;
  14. double total = swimDistance + slowTime;
  15.  
  16. if (total < recordSec){
  17. System.out.printf("Yes, he succeeded! The new world record is %.2f seconds.", total);
  18. }else {
  19. System.out.printf("No, he failed! He was %.2f seconds slower.", total - recordSec);
  20. }
  21.  
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement