triclops200

Untitled

Sep 12th, 2011
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.91 KB | None | 0 0
  1. import javax.swing.JOptionPane;
  2. public class Time2
  3. {
  4.     public static void main(String[] args)
  5.     {
  6.    
  7.         String Input;
  8.         Input = JOptionPane.showInputDialog(null, "How many minutes did you work?");
  9.     //convert Input to a integer.      
  10.         int numMinutes = Integer.parseInt(Input);
  11.     //convert minutes to hours. Ints round down, so you get correct amount.
  12.         int numHours = numMinutes/60;
  13.     //Since numHours rounded down, this equation will give minutes left over.
  14.         numMinutes = numMinutes-(60*numHours);
  15.    
  16.     // shows how many minutes there are on the job.
  17.         System.out.print("Minutes on a job: ");
  18.         System.out.println(numMinutes);
  19.     // shows how many hours were worked on the job.
  20.         System.out.print("Hours on a job: ");
  21.         System.out.println(numHours);        
  22.  
  23.    
  24.     //Dialog output
  25.         JOptionPane.showMessageDialog(null, "You worked " +Integer.toString(numHours)+" Hours and "+Integer.toString(numMinutes)+" minutes.");
  26.  
  27.         }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment