diff --git a/pom.xml b/pom.xml
index 5fd8efa..cfd1ef3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,6 +7,18 @@
io.zipcoder
InterviewProblem5
1.0-SNAPSHOT
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+ 1.6
+ 1.6
+
+
+
+
diff --git a/src/main/java/io/zipcoder/Problem6.java b/src/main/java/io/zipcoder/Problem6.java
index 4ee4e64..e3b5cdc 100644
--- a/src/main/java/io/zipcoder/Problem6.java
+++ b/src/main/java/io/zipcoder/Problem6.java
@@ -1,4 +1,108 @@
package io.zipcoder;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
public class Problem6 {
+
+
+ Map myMap = new HashMap();
+ String[] numberString = {"Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven",
+ "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Ninteen", "Twenty"};
+
+ public Map populateMap() {
+ for (int i = 0; i < numberString.length; i++) {
+ myMap.put(i, numberString[i]);
+ }
+ myMap.put(21, "Twenty One");
+ myMap.put(22, "Twenty Two");
+ myMap.put(23, "Twenty Three");
+ myMap.put(30, "Thirty");
+ myMap.put(40, "Forty");
+ myMap.put(50, "Fifty");
+ return myMap;
+ }
+
+ public String militaryTimeConverter(String input) {
+ myMap = populateMap();
+ String outPut = "";
+ String inputTime="";
+ if(input.contains("am")){
+ inputTime += input.replace("am", "");
+ }else{
+ inputTime+=input.replace("pm","");
+ }
+
+ String[] inputTimeArray = inputTime.split(":");
+ int[] convertedToInt = stringToIntConverter(inputTimeArray);
+ if(input.contains("am")){
+ outPut+=amTimeFormat(convertedToInt[0],myMap);
+ }else{
+ outPut+=pmTimeFormat(convertedToInt[0],myMap);
+ }
+ outPut+=minuteFormat(convertedToInt[1]);
+
+ return outPut;
+ }
+
+ public int[] stringToIntConverter(String[] input) {
+ int[] intArray = new int[0];
+ for (int i = 0; i < input.length; i++) {
+ intArray = Arrays.copyOf(intArray, intArray.length + 1);
+ intArray[i] = Integer.parseInt(String.valueOf(input[i]));
+ }
+ return intArray;
+ }
+
+ public String pmTimeFormat(int inputHour,Map inputMap) {
+ String outPut = "";
+ if (inputHour == 12) {
+ outPut += inputMap.get(inputHour);
+ } else {
+ outPut += inputMap.get(12 + inputHour);
+ }
+ return outPut;
+ }
+
+ public String amTimeFormat(int inputHour,Map inputMap) {
+ String outPut = "";
+ if (inputHour < 10) {
+ outPut += "Zero ";
+ outPut += inputMap.get(inputHour);
+ } else if (inputHour == 12) {
+ outPut += "Zero ";
+ outPut += inputMap.get(0);
+ } else {
+ outPut += inputMap.get(inputHour);
+ }
+ return outPut;
+
+ }
+
+
+ public String minuteFormat(int inputMinute){
+ String outPut="";
+ int divisionByTen = inputMinute / 10;
+ int modulus = inputMinute % 10;
+ if (inputMinute< 24) {
+ outPut += " Hundred and ";
+ if(inputMinute<10){
+ outPut+="Zero ";
+ }
+ outPut += myMap.get(inputMinute);
+ outPut += " Hours";
+ } else {
+ outPut += " Hundred and ";
+ outPut += myMap.get(10 * (divisionByTen));
+ outPut += " ";
+ if (modulus != 0) {
+ outPut += myMap.get(modulus) +" ";
+ }
+ outPut += "Hours";
+
+ }
+ return outPut;
+ }
+
}
diff --git a/src/test/java/io/zipcoder/Problem6Test.java b/src/test/java/io/zipcoder/Problem6Test.java
index d262e88..14ad111 100644
--- a/src/test/java/io/zipcoder/Problem6Test.java
+++ b/src/test/java/io/zipcoder/Problem6Test.java
@@ -1,4 +1,81 @@
package io.zipcoder;
+import org.junit.Assert;
+import org.junit.Test;
+
public class Problem6Test {
+
+ @Test
+ public void testMilitaryTimeConverter1(){
+ Problem6 test = new Problem6();
+ String input = "1:30pm";
+ String expected = "Thirteen Hundred and Thirty Hours";
+
+ String actual = test.militaryTimeConverter(input);
+ Assert.assertEquals(expected,actual);
+ }
+ @Test
+ public void testMilitaryTimeConverter2(){
+ Problem6 test = new Problem6();
+ String input = "7:30pm";
+ String expected = "Ninteen Hundred and Thirty Hours";
+
+ String actual = test.militaryTimeConverter(input);
+ Assert.assertEquals(expected,actual);
+ }
+ @Test
+ public void testMilitaryTimeConverter3(){
+ Problem6 test = new Problem6();
+ String input = "2:11am";
+ String expected = "Zero Two Hundred and Eleven Hours";
+
+ String actual = test.militaryTimeConverter(input);
+ Assert.assertEquals(expected,actual);
+ }
+ @Test
+ public void testMilitaryTimeConverter4(){
+ Problem6 test = new Problem6();
+ String input = "11:55pm";
+ String expected = "Twenty Three Hundred and Fifty Five Hours";
+
+ String actual = test.militaryTimeConverter(input);
+ Assert.assertEquals(expected,actual);
+ }
+
+ @Test
+ public void testMilitaryTimeConverter5(){
+ Problem6 test = new Problem6();
+ String input = "1:22am";
+ String expected = "Zero One Hundred and Twenty Two Hours";
+
+ String actual = test.militaryTimeConverter(input);
+ Assert.assertEquals(expected,actual);
+ }
+
+ @Test
+ public void testMilitaryTimeConverter6(){
+ Problem6 test = new Problem6();
+ String input = "12:00am";
+ String expected = "Zero Zero Hundred and Zero Zero Hours";
+
+ String actual = test.militaryTimeConverter(input);
+ Assert.assertEquals(expected,actual);
+ }
+
+ @Test
+ public void testMilitaryTimeConverter7(){
+ Problem6 test = new Problem6();
+ String input = "12:00pm";
+ String expected = "Twelve Hundred and Zero Zero Hours";
+
+ String actual = test.militaryTimeConverter(input);
+ Assert.assertEquals(expected,actual);
+ }
+
+
+
+
+
+
+
}