galinyotsev123

ProgBasicsExam1and2December2018-E02mountainRun

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