updated readme

This commit is contained in:
rshaghoulian
2017-04-30 18:30:26 -07:00
parent 9b6ef0f13b
commit 7145449310
57 changed files with 287 additions and 268 deletions
@@ -0,0 +1,26 @@
// Author: Rodney Shaghoulian
// Github: github.com/rshaghoulian
// HackerRank: hackerrank.com/rshaghoulian
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
String str = scan.nextLine();
scan.close();
int hours = Integer.parseInt(str.substring(0,2));
int minutes = Integer.parseInt(str.substring(3,5));
int seconds = Integer.parseInt(str.substring(6,8));
/* Convert to 24-hour format */
if (str.substring(8, 10).equals("PM") && hours != 12) {
hours += 12;
} else if (str.substring(8, 10).equals("AM") && hours == 12) {
hours = 0;
}
System.out.format("%02d:%02d:%02d", hours, minutes, seconds);
}
}