title: Convert int to double Java
body: <p>I'm currently having an issue with my code.
  I have to declare hours and minutes as int, and totalTimeHours as double.
  totalTimeHours is used to store the total time in hours, ex 6.555 hrs.
  The problem I'm working on requires the answer to be found in hours and minutes,
  for example. 6 hours and 36 minutes.
  For my final run, I need to use 14.7 for gallons of gas used and 359.5 for distance.
  I used hours = (int)totalTimeHours to extract the whole number 6
  and am supposed to find the remainder of time left over and multiply that by 60 to find minutes,
  but that's where I'm getting held up on.</p>
  
  <p>Below is my code:</p>
  
  <pre><code>  public static void computeMilesPerGallon()
    {   //start brackett for computeMilesPerGallon
  
       double gallons, distance, mpg, totalTimeHours;   //totalTimeHours is the total  time in just hours
                                                                           //for example totalTimeHours = 6.5555 hrs
       int minutes, hours;
       final String DASHES = "-----------------------------------------------";
       final double AVERAGE_SPEED = 54.5;     
  
       DecimalFormat oneDecimalDigits = new DecimalFormat ("0.0");   //prints decimal to 1 places
       DecimalFormat threeDecimalDigits = new DecimalFormat ("0.000");   //prints decimal to 3 places  
  
       System.out.println ("\n\t\t\tSpeed Problem");
       System.out.println ("\t\t\t-------------");
       System.out.print ("\n\t\tEnter in the gallons of gas used: ");   //gets gallons of gas used
       gallons = scan.nextDouble();
  
       System.out.print ("\t\tEnter in the total distance driven: ");   //gets total distance driven
       distance = scan.nextDouble();
  
       mpg = distance / gallons;   //calculates mpg
       System.out.println ("\t\tThis is your miles per gallon (mpg): " + oneDecimalDigits.format(mpg));  
                                                                           //displays mpg
      //calculates time// 
       totalTimeHours = distance / AVERAGE_SPEED;
  
      //below line displays total time in hours to 3 decimal places
       System.out.println ("\n\t\tThis is was your time in hours: " 
                                          + threeDecimalDigits.format(totalTimeHours));
  
      //extracts hours from time in hours
       hours = (int)totalTimeHours;
          minutes = Math.round((totalTimeHours - hours) * 60);
  
      //prints total time in hrs and minutes
       System.out.println ("\t\tThis is the total time in hours and minutes: " + hours 
                                              + " hours and " + minutes + " minutes");  
  
       System.out.println ("\t" + DASHES);
  
    }
  </code></pre>