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

import java.util.Scanner; import java.math.RoundingMode; /** * * @author Latisha

ID: 3546377 • Letter: I

Question

import java.util.Scanner;

import java.math.RoundingMode;

/**

*

* @author Latisha Vincent

*/

public class DownloadTimeApp {


       public static void main(String[] args) {

         

          

            // display operational messages

        System.out.println("Welcome to the Download Time Estimator.");

        System.out.println();  // print a blank line

                         

              // get file size from the user

                

        System.out.println("Enter file size (MB): ");

        Scanner sc = new Scanner (System.in);

           float secondsTime = 0;

           int hoursTime = minutesTime * 1;

           int minutesTime = hoursTime/60;

           int secondsTotal;

           secondsTotal = sc.nextInt(Math.round(secondsTime)/hoursTime);     

                

           secondsTotal = sc.nextInt(Math.round(secondsTime)/hoursTime);

                

               System.out.println("Enter download speed (MB/sec): ");

                int downloadSpeed = sc.nextInt();

                

              

     String choice = "y";

            while (choice.contentEquals ("y"));

                minutesTime = hoursTime/60;

                hoursTime = minutesTime * 1;

                System.out.println();  // print a blank line

                

                //display the results

                String message;

            message = "This Download will take approximately   hours" + hoursTime + "   minutes" + minutesTime +  "   seconds" + secondsTotal;

            

            //see if user wants to continue

            System.out.print("Continue: (y/n):  ");

            choice = sc.next();

            System.out.println();

            

           

        }

    }

  

Explanation / Answer

I dont understand what your code is supposed to do but the problem lies in following part:



int hoursTime = minutesTime * 1;

int minutesTime = hoursTime/60;


You are using minutesTime before declaring it so that is an error.

If you declare them like this:


int minutesTime = hoursTime/60;

int hoursTime = minutesTime * 1;


then also its an error. You need to fix the value one variable. Declare it first and use it to calculate the second variable.