476179

5.3.3Act1

Oct 24th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1.  
  2. <!DOCTYPE html>
  3. <html lang="en>">
  4. <head>
  5. <meta charset="utf-8">
  6. <title>5F act 3</title>
  7. </head>
  8.  
  9. <body>
  10. <script>
  11.  
  12. alert("Hello! This program will calculate how long it will take you to arrive at your destination.");
  13.  
  14. var distance, speed, time1, time2;
  15.  
  16. distance = prompt("enter how far you will travel in km/h");
  17. distance = parseFloat(distance)
  18. speed = prompt("enter the average spped at which you will travel in km/h");
  19. speed = parseFloat(speed)
  20.  
  21. time1 = distance / speed;
  22. time2 = time1.toFixed(2)
  23.  
  24. alert("trip distance: "+ distance +" km \naverage speed: "+speed +" km/h \nestimated time to arrival: "+ time2 +" hour(s)");
  25.  
  26. </script>
  27. </body>
  28.  
  29. </html>
Advertisement
Add Comment
Please, Sign In to add comment