Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Provide Source Code: 1. Start a new project named ch03_ex3_DownloadTime that con

ID: 3549113 • Letter: P

Question

Provide Source Code:


1. Start a new project named ch03_ex3_DownloadTime that contains a class named DownloadTimeApp that has a main method.

2. Add the code that gets input from the user and displays output. To do that, you can copy code from another similar application and modify it so it's appropriate for this application.

3. Add the code that calculates the hours, minutes and seconds needed to download the specified file size at the specified download speed. To do that, start by calculating the download time in seconds and then rounding that value to an integer. Then, divide the total seconds by the number of seconds in an hour to get the number of hours, and divide the remaining seconds by the number of seconds in a minute to get the number of minutes. Note that this application only calculates an approximate value, so you don't need to use Big Decimal arithmetic.

4. Test the application to make sure it works correctly.


                    You need the source code to the Murach's Java Programming book found here:                 

                    http://www.murach.com/downloads/javp.htm                 

Explanation / Answer

package ch03_ex3_DownloadTime;


import java.util.Scanner;


public class DownloadTimeApp

{

public static void main(String args[])

{

Scanner scanner = new Scanner(System.in);

System.out.println("Please input the file size in bytes");

Double total_bytes = scanner.nextDouble(); // Stores file size in bytes

System.out.println("Please input the download speed in byte/second");

Double speed = scanner.nextDouble(); // Stores download speed in byte/second

int total_seconds = (int) (total_bytes/speed); // Stores total seconds required

int total_hours = total_seconds/3600; // Stores total hours required

int total_mins = (total_seconds%3600)/60; // Stores total mins required

int remaining_secs = (total_seconds%60); // Stores remaining seconds required

System.out.println("Time required: Hours = " + total_hours + "; Minutes = " + total_mins + "; Seconds = " + remaining_secs);

}


}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote