Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Programmer: Jessica Sparks
- Date: March 22, 2017
- Filename: DownloadTimeApp.java
- Purpose: This program will calculate the estimated time to download the file and will display information to the user.
- */
- import javax.swing.JOptionPane;
- public class DownloadTimeApp
- {
- public static void main(String args[])
- {
- String WELCOME_LINE = "Welcome to the Download Time Estimator";
- String fileSizeInput;
- String downloadSpeedInput;
- int fileSize = 0;
- int downloadSpeed = 0;
- int totalInSeconds;
- int totalInMinutes;
- int downloadMinutes;
- int downloadHours;
- int downloadSeconds;
- // Get user input
- fileSizeInput = JOptionPane.showInputDialog("Enter file Size (MB):");
- // Get user input
- downloadSpeedString = JOptionPane.showInputDialog("Enter Download speed (MB/Sec):");
- fileSize = Integer.parseInt(fileSizeInput);
- downloadSpeed = Integer.parseInt(downloadSpeedInput);
- totalInSeconds = fileSize / downloadSpeed;
- downloadSeconds = totalInSeconds % 60;
- totalInMinutes = totalInSeconds / 60;
- if(totalInMinutes >=60)
- {
- downloadHours = totalInMinutes/60;
- downloadMinutes = totalInMinutes%60;
- } else {
- downloadHours = 0;
- downloadMinutes = totalInMinutes;
- //Produce output to the user.
- output WELCOME_LINE;
- println();
- output "This download will take approximately" ",downloadHours," "hours" ",downloadMinutes," "minutes" ",downloadSeconds," "seconds."
- System.out.println(0);
- stop
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement