Skip to content

Instantly share code, notes, and snippets.

@spaghettiSyntax
Last active December 5, 2017 14:54
Show Gist options
  • Save spaghettiSyntax/d424a79e374b9c08b75ef0df2a9c7b6a to your computer and use it in GitHub Desktop.
Save spaghettiSyntax/d424a79e374b9c08b75ef0df2a9c7b6a to your computer and use it in GitHub Desktop.
Think Java code snippets.
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