Last active
December 5, 2017 14:54
-
-
Save spaghettiSyntax/d424a79e374b9c08b75ef0df2a9c7b6a to your computer and use it in GitHub Desktop.
Think Java code snippets.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Time { | |
public static void main(String[] args) { | |
int hour, minute, second; | |
// Comments when started program, syntax when finished. | |
// hour = 23; | |
hour = 23; | |
// minute = 49; | |
minute = 59; | |
// second = 30; | |
second = 58; | |
double percentage = (hour * 100) / 24; | |
System.out.println("Seconds since midnight."); | |
System.out.println((60 * 60) * hour + (minute * 60) + second); | |
System.out.println("Seconds until midnight."); | |
System.out.println((60 * 60) * (24 - hour) + (minute * 60) + second); | |
System.out.println("Percentage of day passed."); | |
System.out.println(percentage); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment