Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Lesson 32 Coding Activity 4
- *
- * For the Lesson 32 activities, you will be asked to write one or more methods.
- * Use the template to write a main method that tests each of your methods,
- * then paste everything into the code runner box. Your submission should
- * begin with the first import statement and end with the final }.
- *
- * This method must be called realTime() and its parameter must be an integer.
- *
- * Calling realTime(6342) would print the following:
- *
- * Hours: 1
- * Minutes: 45
- * Seconds: 42
- */
- import java.util.Scanner;
- class Lesson_32_Activity_Four {
- public static void realTime(int n)
- {
- int l = n;
- int hour = n/3600;
- l = l-(hour*3600);
- int minutes = l/60;
- l = l-(minutes*60);
- System.out.println("Hours: " + hour);
- System.out.println("Minutes: " + minutes);
- System.out.println("Seconds: " + l);
- }
- public static void main(String[] args)
- {
- Scanner scan = new Scanner(System.in);
- int x = scan.nextInt();
- realTime(x);
- }
- }
Add Comment
Please, Sign In to add comment