Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. /*
  2. Programmer: Jessica Sparks
  3. Date: March 22, 2017
  4. Filename: DownloadTimeApp.java
  5. Purpose: This program will calculate the estimated time to download the file and will display information to the user.
  6. */
  7. import javax.swing.JOptionPane;
  8.  
  9. public class DownloadTimeApp
  10. {
  11. public static void main(String args[])
  12. {
  13. String WELCOME_LINE = "Welcome to the Download Time Estimator";
  14. String fileSizeInput;
  15. String downloadSpeedInput;
  16. int fileSize = 0;
  17. int downloadSpeed = 0;
  18. int totalInSeconds;
  19. int totalInMinutes;
  20. int downloadMinutes;
  21. int downloadHours;
  22. int downloadSeconds;
  23.  
  24. // Get user input
  25. fileSizeInput = JOptionPane.showInputDialog("Enter file Size (MB):");
  26.  
  27. // Get user input
  28. downloadSpeedString = JOptionPane.showInputDialog("Enter Download speed (MB/Sec):");
  29.  
  30. fileSize = Integer.parseInt(fileSizeInput);
  31.  
  32. downloadSpeed = Integer.parseInt(downloadSpeedInput);
  33.  
  34. totalInSeconds = fileSize / downloadSpeed;
  35. downloadSeconds = totalInSeconds % 60;
  36. totalInMinutes = totalInSeconds / 60;
  37. if(totalInMinutes >=60)
  38. {
  39. downloadHours = totalInMinutes/60;
  40. downloadMinutes = totalInMinutes%60;
  41. } else {
  42. downloadHours = 0;
  43. downloadMinutes = totalInMinutes;
  44.  
  45.  
  46. //Produce output to the user.
  47. output WELCOME_LINE;
  48. println();
  49. output "This download will take approximately" ",downloadHours," "hours" ",downloadMinutes," "minutes" ",downloadSeconds," "seconds."
  50. System.out.println(0);
  51.  
  52. stop
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement