StefanTobler

Lesson 32 Activity 4

Dec 3rd, 2016
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.13 KB | None | 0 0
  1. /*
  2. * Lesson 32 Coding Activity 4
  3. *
  4. * For the Lesson 32 activities, you will be asked to write one or more methods.
  5. * Use the template to write a main method that tests each of your methods,
  6. * then paste everything into the code runner box. Your submission should
  7. * begin with the first import statement and end with the final }.
  8. *
  9. * This method must be called realTime() and its parameter must be an integer.
  10. *
  11. * Calling realTime(6342) would print the following:
  12. *
  13. * Hours: 1
  14. * Minutes: 45
  15. * Seconds: 42
  16. */
  17.  
  18.  
  19. import java.util.Scanner;
  20.  
  21. class Lesson_32_Activity_Four {
  22.      
  23.         public static void realTime(int n)
  24.         {
  25.           int l = n;
  26.           int hour = n/3600;
  27.           l = l-(hour*3600);
  28.           int minutes = l/60;
  29.           l = l-(minutes*60);
  30.           System.out.println("Hours: " + hour);
  31.           System.out.println("Minutes: " + minutes);
  32.           System.out.println("Seconds: " + l);
  33.         }
  34.        
  35.         public static void main(String[] args)
  36.          {
  37.          Scanner scan = new Scanner(System.in);
  38.          int x = scan.nextInt();
  39.          realTime(x);
  40.          }
  41. }
Add Comment
Please, Sign In to add comment