Untitled
unknown
plain_text
a year ago
929 B
3
Indexable
Never
public static void main(String[] args) { long currentTimeMillis = System.currentTimeMillis(); long MinutesInMillis = 5 * 60 * 1000; // 5 minutes in milliseconds // Simulate 1 hour before the current time long oneHourInMillis = 5 * 60 * 60 * 1000; long yourGivenTimeInMillis = currentTimeMillis - oneHourInMillis; long intervalsPassed = (currentTimeMillis - yourGivenTimeInMillis) / MinutesInMillis; double percentage = intervalsPassed * 0.232; double result = 100 - percentage; if (percentage >= 100 || result < 0) { result = 0; } double roundedResult = Math.floor(result * 100) / 100; System.out.println("Intervals Passed: " + intervalsPassed); System.out.println("Percentage to remove: " + percentage); System.out.println("Energy result: " + roundedResult); }