diff --git a/HW2/.idea/misc.xml b/HW2/.idea/misc.xml new file mode 100644 index 0000000..0548357 --- /dev/null +++ b/HW2/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/HW2/.idea/modules.xml b/HW2/.idea/modules.xml new file mode 100644 index 0000000..1e0ea4b --- /dev/null +++ b/HW2/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/HW2/.idea/workspace.xml b/HW2/.idea/workspace.xml new file mode 100644 index 0000000..77cea33 --- /dev/null +++ b/HW2/.idea/workspace.xml @@ -0,0 +1,469 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1523488253280 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Jackson_Maschman_HW2/HW2/HW2.iml b/Jackson_Maschman_HW2/HW2/HW2.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/Jackson_Maschman_HW2/HW2/HW2.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Jackson_Maschman_HW2/HW2/out/production/HW2/HW2_1.class b/Jackson_Maschman_HW2/HW2/out/production/HW2/HW2_1.class new file mode 100644 index 0000000..ed98185 Binary files /dev/null and b/Jackson_Maschman_HW2/HW2/out/production/HW2/HW2_1.class differ diff --git a/Jackson_Maschman_HW2/HW2/out/production/HW2/HW2_2.class b/Jackson_Maschman_HW2/HW2/out/production/HW2/HW2_2.class new file mode 100644 index 0000000..188b22e Binary files /dev/null and b/Jackson_Maschman_HW2/HW2/out/production/HW2/HW2_2.class differ diff --git a/Jackson_Maschman_HW2/HW2/out/production/HW2/HW2_3.class b/Jackson_Maschman_HW2/HW2/out/production/HW2/HW2_3.class new file mode 100644 index 0000000..e7b32e6 Binary files /dev/null and b/Jackson_Maschman_HW2/HW2/out/production/HW2/HW2_3.class differ diff --git a/Jackson_Maschman_HW2/HW2/out/production/HW2/StringArray.class b/Jackson_Maschman_HW2/HW2/out/production/HW2/StringArray.class new file mode 100644 index 0000000..75df6ca Binary files /dev/null and b/Jackson_Maschman_HW2/HW2/out/production/HW2/StringArray.class differ diff --git a/Jackson_Maschman_HW2/HW2/src/HW2_1.java b/Jackson_Maschman_HW2/HW2/src/HW2_1.java new file mode 100644 index 0000000..6296068 --- /dev/null +++ b/Jackson_Maschman_HW2/HW2/src/HW2_1.java @@ -0,0 +1,52 @@ +import java.util.Scanner; +public class HW2_1 { + + public static void main(String[] args) + { + Scanner scan = new Scanner(System.in); + StringArray a; + a = new StringArray(); + //Brings each sentence into an array + while(scan.hasNext()) + { + a.add(scan.next()); + } + + //Checks for largest word + + int Word = a.array[0].length(); + + for(int x = 0; x < a.size; x++) + { + if(Word < a.array[x].length()) + { + Word = a.array[x].length(); + } + } + + String Sentence1 = "+--"; + + for(int b = 0; b < Word; b++) + { + Sentence1 = Sentence1 + "-"; + } + + Sentence1 = Sentence1 + "+"; + + System.out.println(Sentence1); + + for(int y = 0; y < a.size; y++) + { + String Sentence2 = "| "; + Sentence2 = Sentence2 + a.array[y]; + for(int d = 0; d < (Word - a.array[y].length()); d++) + { + Sentence2 = Sentence2 + " "; + } + Sentence2 = Sentence2 + " |"; + System.out.println(Sentence2); + } + System.out.println(Sentence1); + + } +} diff --git a/Jackson_Maschman_HW2/HW2/src/HW2_2.java b/Jackson_Maschman_HW2/HW2/src/HW2_2.java new file mode 100644 index 0000000..b00d609 --- /dev/null +++ b/Jackson_Maschman_HW2/HW2/src/HW2_2.java @@ -0,0 +1,749 @@ +import java.util.Scanner; + +public class HW2_2 { + + public static void main(String[] args) + { + Scanner scan = new Scanner(System.in); + String j = scan.nextLine(); + j.replaceAll("\\s",""); + int z = Character.getNumericValue(j.charAt(0)); + int y = Character.getNumericValue(j.charAt(1)); + int x = Character.getNumericValue(j.charAt(2)); + int w = Character.getNumericValue(j.charAt(3)); + int v = Character.getNumericValue(j.charAt(4)); + int u = Character.getNumericValue(j.charAt(5)); + int t = Character.getNumericValue(j.charAt(6)); + + for(int a = 0; a < 3; a++) + { + String Phone = ""; + if(z == 2 && a == 0) + { + Phone = Phone + "a"; + } + if(z == 2 && a == 1) + { + Phone = Phone + "b"; + } + if(z == 2 && a == 2) + { + Phone = Phone + "c"; + } + if(z == 3 && a == 0) + { + Phone = Phone + "d"; + } + if(z == 3 && a == 1) + { + Phone = Phone + "e"; + } + if(z == 3 && a == 2) + { + Phone = Phone + "f"; + } + if(z == 4 && a == 0) + { + Phone = Phone + "g"; + } + if(z == 4 && a == 1) + { + Phone = Phone + "h"; + } + if(z == 4 && a == 2) + { + Phone = Phone + "i"; + } + if(z == 5 && a == 0) + { + Phone = Phone + "j"; + } + if(z == 5 && a == 1) + { + Phone = Phone + "k"; + } + if(z == 5 && a == 2) + { + Phone = Phone + "l"; + } + if(z == 6 && a == 0) + { + Phone = Phone + "m"; + } + if(z == 6 && a == 1) + { + Phone = Phone + "n"; + } + if(z == 6 && a == 2) + { + Phone = Phone + "o"; + } + if(z == 7 && a == 0) + { + Phone = Phone + "p"; + } + if(z == 7 && a == 1) + { + Phone = Phone + "r"; + } + if(z == 7 && a == 2) + { + Phone = Phone + "s"; + } + if(z == 8 && a == 0) + { + Phone = Phone + "t"; + } + if(z == 8 && a == 1) + { + Phone = Phone + "u"; + } + if(z == 8 && a == 2) + { + Phone = Phone + "v"; + } + if(z == 9 && a == 0) + { + Phone = Phone + "w"; + } + if(z == 9 && a == 1) + { + Phone = Phone + "x"; + } + if(z == 9 && a == 2) + { + Phone = Phone + "y"; + } + if(z == 1 || z == 0) + { + Phone = Phone + " "; + } + for(int b = 0; b < 3; b++) + { + String Phone1 = Phone; + if(y == 2 && b == 0) + { + Phone1 = Phone1 + "a"; + } + if(y == 2 && b == 1) + { + Phone1 = Phone1 + "b"; + } + if(y == 2 && b == 2) + { + Phone1 = Phone1 + "c"; + } + if(y == 3 && b == 0) + { + Phone1 = Phone1 + "d"; + } + if(y == 3 && b == 1) + { + Phone1 = Phone1 + "e"; + } + if(y == 3 && b == 2) + { + Phone1 = Phone1 + "f"; + } + if(y == 4 && b == 0) + { + Phone1 = Phone1 + "g"; + } + if(y == 4 && b == 1) + { + Phone1 = Phone1 + "h"; + } + if(y == 4 && b == 2) + { + Phone1 = Phone1 + "i"; + } + if(y == 5 && b == 0) + { + Phone1 = Phone1 + "j"; + } + if(y == 5 && b == 1) + { + Phone1 = Phone1 + "k"; + } + if(y == 5 && b == 2) + { + Phone1 = Phone1 + "l"; + } + if(y == 6 && b == 0) + { + Phone1 = Phone1 + "m"; + } + if(y == 6 && b == 1) + { + Phone1 = Phone1 + "n"; + } + if(y == 6 && b == 2) + { + Phone1 = Phone1 + "o"; + } + if(y == 7 && b == 0) + { + Phone1 = Phone1 + "p"; + } + if(y == 7 && b == 1) + { + Phone1 = Phone1 + "r"; + } + if(y == 7 && b == 2) + { + Phone1 = Phone1 + "s"; + } + if(y == 8 && b == 0) + { + Phone1 = Phone1 + "t"; + } + if(y == 8 && b == 1) + { + Phone1 = Phone1 + "u"; + } + if(y == 8 && b == 2) + { + Phone1 = Phone1 + "v"; + } + if(y == 9 && b == 0) + { + Phone1 = Phone1 + "w"; + } + if(y == 9 && b == 1) + { + Phone1 = Phone1 + "x"; + } + if(y == 9 && b == 2) + { + Phone1 = Phone1 + "y"; + } + if(y == 1 || y == 0) + { + Phone1 = Phone1 + " "; + } + for(int c = 0; c < 3; c++) + { + String Phone2 = Phone1; + if(x == 2 && c == 0) + { + Phone2 = Phone2 + "a"; + } + if(x == 2 && c == 1) + { + Phone2 = Phone2 + "b"; + } + if(x == 2 && c == 2) + { + Phone2 = Phone2 + "c"; + } + if(x == 3 && c == 0) + { + Phone2 = Phone2 + "d"; + } + if(x == 3 && c == 1) + { + Phone2 = Phone2 + "e"; + } + if(x == 3 && c == 2) + { + Phone2 = Phone2 + "f"; + } + if(x == 4 && c == 0) + { + Phone2 = Phone2 + "g"; + } + if(x == 4 && c == 1) + { + Phone2 = Phone2 + "h"; + } + if(x == 4 && c == 2) + { + Phone2 = Phone2 + "i"; + } + if(x == 5 && c == 0) + { + Phone2 = Phone2 + "j"; + } + if(x == 5 && c == 1) + { + Phone2 = Phone2 + "k"; + } + if(x == 5 && c == 2) + { + Phone2 = Phone2 + "l"; + } + if(x == 6 && c == 0) + { + Phone2 = Phone2 + "m"; + } + if(x == 6 && c == 1) + { + Phone2 = Phone2 + "n"; + } + if(x == 6 && c == 2) + { + Phone2 = Phone2 + "o"; + } + if(x == 7 && c == 0) + { + Phone2 = Phone2 + "p"; + } + if(x == 7 && c == 1) + { + Phone2 = Phone2 + "r"; + } + if(x == 7 && c == 2) + { + Phone2 = Phone2 + "s"; + } + if(x == 8 && c == 0) + { + Phone2 = Phone2 + "t"; + } + if(x == 8 && c == 1) + { + Phone2 = Phone2 + "u"; + } + if(x == 8 && c == 2) + { + Phone2 = Phone2 + "v"; + } + if(x == 9 && c == 0) + { + Phone2 = Phone2 + "w"; + } + if(x == 9 && c == 1) + { + Phone2 = Phone2 + "x"; + } + if(x == 9 && c == 2) + { + Phone2 = Phone2 + "y"; + } + if(x == 1 || x == 0) + { + Phone2 = Phone2+ " "; + } + for(int d = 0; d < 3; d++) + { + String Phone3 = Phone2; + if(w == 2 && d == 0) + { + Phone3 = Phone3 + "a"; + } + if(w == 2 && d == 1) + { + Phone3 = Phone3 + "b"; + } + if(w == 2 && d == 2) + { + Phone3 = Phone3 + "c"; + } + if(w == 3 && d == 0) + { + Phone3 = Phone3 + "d"; + } + if(w == 3 && d == 1) + { + Phone3 = Phone3 + "e"; + } + if(w == 3 && d == 2) + { + Phone3 = Phone3 + "f"; + } + if(w == 4 && d == 0) + { + Phone3 = Phone3 + "g"; + } + if(w == 4 && d == 1) + { + Phone3 = Phone3 + "h"; + } + if(w == 4 && d == 2) + { + Phone3 = Phone3 + "i"; + } + if(w == 5 && d == 0) + { + Phone3 = Phone3 + "j"; + } + if(w == 5 && d == 1) + { + Phone3 = Phone3 + "k"; + } + if(w == 5 && d == 2) + { + Phone3 = Phone3 + "l"; + } + if(w == 6 && d == 0) + { + Phone3 = Phone3 + "m"; + } + if(w == 6 && d == 1) + { + Phone3 = Phone3 + "n"; + } + if(w == 6 && d == 2) + { + Phone3 = Phone3 + "o"; + } + if(w == 7 && d == 0) + { + Phone3 = Phone3 + "p"; + } + if(w == 7 && d == 1) + { + Phone3 = Phone3 + "r"; + } + if(w == 7 && d == 2) + { + Phone3 = Phone3 + "s"; + } + if(w == 8 && d == 0) + { + Phone3 = Phone3 + "t"; + } + if(w == 8 && d == 1) + { + Phone3 = Phone3 + "u"; + } + if(w == 8 && d == 2) + { + Phone3 = Phone3 + "v"; + } + if(w == 9 && d == 0) + { + Phone3 = Phone3 + "w"; + } + if(w == 9 && d == 1) + { + Phone3 = Phone3 + "x"; + } + if(w == 9 && d == 2) + { + Phone3 = Phone3 + "y"; + } + if(w == 1 || w == 0) + { + Phone3 = Phone3 + " "; + } + for(int e = 0; e < 3; e++) + { + String Phone4 = Phone3; + if(v == 2 && e == 0) + { + Phone4 = Phone4 + "a"; + } + if(v == 2 && e == 1) + { + Phone4 = Phone4 + "b"; + } + if(v == 2 && e == 2) + { + Phone4 = Phone4 + "c"; + } + if(v == 3 && e == 0) + { + Phone4 = Phone4 + "d"; + } + if(v == 3 && e == 1) + { + Phone4 = Phone4 + "e"; + } + if(v == 3 && e == 2) + { + Phone4 = Phone4 + "f"; + } + if(v == 4 && e == 0) + { + Phone4 = Phone4 + "g"; + } + if(v == 4 && e == 1) + { + Phone4 = Phone4 + "h"; + } + if(v == 4 && e == 2) + { + Phone4 = Phone4 + "i"; + } + if(v == 5 && e == 0) + { + Phone4 = Phone4 + "j"; + } + if(v == 5 && e == 1) + { + Phone4 = Phone4 + "k"; + } + if(v == 5 && e == 2) + { + Phone4 = Phone4 + "l"; + } + if(v == 6 && e == 0) + { + Phone4 = Phone4 + "m"; + } + if(v == 6 && e == 1) + { + Phone4 = Phone4 + "n"; + } + if(v == 6 && e == 2) + { + Phone4 = Phone4 + "o"; + } + if(v == 7 && e == 0) + { + Phone4 = Phone4 + "p"; + } + if(v == 7 && e == 1) + { + Phone4 = Phone4 + "r"; + } + if(v == 7 && e == 2) + { + Phone4 = Phone4 + "s"; + } + if(v == 8 && e == 0) + { + Phone4 = Phone4 + "t"; + } + if(v == 8 && e == 1) + { + Phone4 = Phone4 + "u"; + } + if(v == 8 && e == 2) + { + Phone4 = Phone4 + "v"; + } + if(v == 9 && e == 0) + { + Phone4 = Phone4 + "w"; + } + if(v == 9 && e == 1) + { + Phone4 = Phone4 + "x"; + } + if(v == 9 && e == 2) + { + Phone4 = Phone4 + "y"; + } + if(v == 1 || v == 0) + { + Phone4 = Phone4 + " "; + } + for(int f = 0; f < 3; f++) + { + String Phone5 = Phone4; + if(u == 2 && f == 0) + { + Phone5 = Phone5 + "a"; + } + if(u == 2 && f == 1) + { + Phone5 = Phone5 + "b"; + } + if(u == 2 && f == 2) + { + Phone5 = Phone5 + "c"; + } + if(u == 3 && f == 0) + { + Phone5 = Phone5 + "d"; + } + if(u == 3 && f == 1) + { + Phone5 = Phone5 + "e"; + } + if(u == 3 && f == 2) + { + Phone5 = Phone5 + "f"; + } + if(u == 4 && f == 0) + { + Phone5 = Phone5 + "g"; + } + if(u == 4 && f == 1) + { + Phone5 = Phone5 + "h"; + } + if(u == 4 && f == 2) + { + Phone5 = Phone5 + "i"; + } + if(u == 5 && f == 0) + { + Phone5 = Phone5 + "j"; + } + if(u == 5 && f == 1) + { + Phone5 = Phone5 + "k"; + } + if(u == 5 && f == 2) + { + Phone5 = Phone5 + "l"; + } + if(u == 6 && f == 0) + { + Phone5 = Phone5 + "m"; + } + if(u == 6 && f == 1) + { + Phone5 = Phone5 + "n"; + } + if(u == 6 && f == 2) + { + Phone5 = Phone5 + "o"; + } + if(u == 7 && f == 0) + { + Phone5 = Phone5 + "p"; + } + if(u == 7 && f == 1) + { + Phone5 = Phone5 + "r"; + } + if(u == 7 && f == 2) + { + Phone5 = Phone5 + "s"; + } + if(u == 8 && f == 0) + { + Phone5 = Phone5 + "t"; + } + if(u == 8 && f == 1) + { + Phone5 = Phone5 + "u"; + } + if(u == 8 && f == 2) + { + Phone5 = Phone5 + "v"; + } + if(u == 9 && f == 0) + { + Phone5 = Phone5 + "w"; + } + if(u == 9 && f == 1) + { + Phone5 = Phone5 + "x"; + } + if(u == 9 && f == 2) + { + Phone5 = Phone5 + "y"; + } + if(u == 1 || u == 0) + { + Phone5 = Phone5 + " "; + } + for(int g = 0; g < 3; g++) + { + String Phone6 = Phone5; + if(t == 2 && g == 0) + { + Phone6 = Phone6 + "a"; + } + if(t == 2 && g == 1) + { + Phone6 = Phone6 + "b"; + } + if(t == 2 && g == 2) + { + Phone6 = Phone6 + "c"; + } + if(t == 3 && g == 0) + { + Phone6 = Phone6 + "d"; + } + if(t == 3 && g == 1) + { + Phone6 = Phone6 + "e"; + } + if(t == 3 && g == 2) + { + Phone6 = Phone6 + "f"; + } + if(t == 4 && g == 0) + { + Phone6 = Phone6 + "g"; + } + if(t == 4 && g == 1) + { + Phone6 = Phone6 + "h"; + } + if(t == 4 && g == 2) + { + Phone6 = Phone6 + "i"; + } + if(t == 5 && g == 0) + { + Phone6 = Phone6 + "j"; + } + if(t == 5 && g == 1) + { + Phone6 = Phone6 + "k"; + } + if(t == 5 && g == 2) + { + Phone6 = Phone6 + "l"; + } + if(t == 6 && g == 0) + { + Phone6 = Phone6 + "m"; + } + if(t == 6 && g == 1) + { + Phone6 = Phone6 + "n"; + } + if(t == 6 && g == 2) + { + Phone6 = Phone6 + "o"; + } + if(t == 7 && g == 0) + { + Phone6 = Phone6 + "p"; + } + if(t == 7 && g == 1) + { + Phone6 = Phone6 + "r"; + } + if(t == 7 && g == 2) + { + Phone6 = Phone6 + "s"; + } + if(t == 8 && g == 0) + { + Phone6 = Phone6 + "t"; + } + if(t == 8 && g == 1) + { + Phone6 = Phone6 + "u"; + } + if(t == 8 && g == 2) + { + Phone6 = Phone6 + "v"; + } + if(t == 9 && g == 0) + { + Phone6 = Phone6 + "w"; + } + if(t == 9 && g == 1) + { + Phone6 = Phone6 + "x"; + } + if(t == 9 && g == 2) + { + Phone6 = Phone6 + "y"; + } + if(t == 1 || t == 0) + { + Phone6 = Phone6 + " "; + } + System.out.println(Phone6); + } + } + } + } + } + } + } + + } +} diff --git a/Jackson_Maschman_HW2/HW2/src/HW2_3.java b/Jackson_Maschman_HW2/HW2/src/HW2_3.java new file mode 100644 index 0000000..d2c7339 --- /dev/null +++ b/Jackson_Maschman_HW2/HW2/src/HW2_3.java @@ -0,0 +1,149 @@ +import java.util.Scanner; + +public class HW2_3 +{ + + public static void main(String[] args) + { + Scanner scan = new Scanner(System.in); + int result = 0; + int x; + int y; + int z = 0; + int i = 0; + String Roman = scan.nextLine(); + while(i < (Roman.length())) { + if (i == (Roman.length() - 1)) { + switch (Roman.charAt(i)) { + default: + x = 0; + break; + case 'M': + x = 1000; + break; + case 'D': + x = 500; + break; + case 'C': + x = 100; + break; + case 'L': + x = 50; + break; + case 'X': + x = 10; + break; + case 'V': + x = 5; + break; + case 'I': + x = 1; + break; + } + result = result + x; + break; + } + if (i < (Roman.length() - 2)) + { + switch (Roman.charAt(i + 2)) + { + default: + z = 0; + break; + case 'M': + z = 1000; + break; + case 'D': + z = 500; + break; + case 'C': + z = 100; + break; + case 'L': + z = 50; + break; + case 'X': + z = 10; + break; + case 'V': + z = 5; + break; + case 'I': + z = 1; + break; + } + } + switch (Roman.charAt(i)) { + default: + x = 0; + break; + case 'M': + x = 1000; + break; + case 'D': + x = 500; + break; + case 'C': + x = 100; + break; + case 'L': + x = 50; + break; + case 'X': + x = 10; + break; + case 'V': + x = 5; + break; + case 'I': + x = 1; + break; + } + switch (Roman.charAt(i + 1)) + { + default: + y = 0; + break; + case 'M': + y = 1000; + break; + case 'D': + y = 500; + break; + case 'C': + y = 100; + break; + case 'L': + y = 50; + break; + case 'X': + y = 10; + break; + case 'V': + y = 5; + break; + case 'I': + y = 1; + break; + } + + if(y <= x) + { + result = result + x; + i = i + 1; + } + if(y > x) + { + result = result + (y - x); + i = i + 2; + } + if(z > x) + { + System.out.println("Error: Not A Roman Numeral"); + System.exit(0); + } + z = 0; + } + System.out.println(result); + } +} diff --git a/Jackson_Maschman_HW2/HW2/src/StringArray.java b/Jackson_Maschman_HW2/HW2/src/StringArray.java new file mode 100644 index 0000000..9971dc9 --- /dev/null +++ b/Jackson_Maschman_HW2/HW2/src/StringArray.java @@ -0,0 +1,23 @@ +public class StringArray { + + public String[] array; + public int size; + + public StringArray() { + size = 0; + array = new String[size]; + } + + public void add(String value) { + size = size + 1; + String[] tempArray; + tempArray = new String[size]; + + for(int i=0; i< size - 1; i++) { + tempArray[i] = array[i]; + } + + array = tempArray; + array[size - 1] = value; + } +} diff --git a/Problems/Problem 1.md b/Problems/Problem 1.md index 8cbbe4e..ed22d65 100644 --- a/Problems/Problem 1.md +++ b/Problems/Problem 1.md @@ -3,12 +3,16 @@ You will be given one sentance. Your need to take that sentance and print it out one word per line. I also want you to put a box around the collection of words. Note that there is a space before each word, and after the longest word. Sample Input: +~~~ This is an example. +~~~ Sample Output: +~~~ +----------+ | This | | is       | | an     | | example. | +----------+ +~~~ diff --git a/Problems/Problem 2.md b/Problems/Problem 2.md index 1797499..167b57d 100644 --- a/Problems/Problem 2.md +++ b/Problems/Problem 2.md @@ -4,6 +4,7 @@ In this problem you will be given a 7 digit phone number. Using the assiciation find all possible strings that could replace the numbers. If a number doesn't have any letters associated with it, put a space in for that number. +~~~ 2: abc 3: def 4: ghi @@ -12,11 +13,15 @@ associated with it, put a space in for that number. 7: prs 8: tuv 9: wxy +~~~ Example input (If the number was 3 digits long instead of 7): +~~~ 204 +~~~ Example Output: +~~~ a g a h a i @@ -26,3 +31,4 @@ b i c g c h c i +~~~ diff --git a/Student Work/BenWortmanHW2/BenWortman#1 b/Student Work/BenWortmanHW2/BenWortman#1 new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/Student Work/BenWortmanHW2/BenWortman#1 @@ -0,0 +1 @@ + diff --git a/Student Work/BenWortmanHW2/BenWortman#2 b/Student Work/BenWortmanHW2/BenWortman#2 new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/Student Work/BenWortmanHW2/BenWortman#2 @@ -0,0 +1 @@ + diff --git a/Student Work/BenWortmanHW2/BenWortman#3 b/Student Work/BenWortmanHW2/BenWortman#3 new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/Student Work/BenWortmanHW2/BenWortman#3 @@ -0,0 +1 @@ + diff --git a/Student Work/JPohlmann/HW2/.idea/misc.xml b/Student Work/JPohlmann/HW2/.idea/misc.xml new file mode 100644 index 0000000..29ebe0f --- /dev/null +++ b/Student Work/JPohlmann/HW2/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Student Work/JPohlmann/HW2/.idea/modules.xml b/Student Work/JPohlmann/HW2/.idea/modules.xml new file mode 100644 index 0000000..1e0ea4b --- /dev/null +++ b/Student Work/JPohlmann/HW2/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Student Work/JPohlmann/HW2/.idea/workspace.xml b/Student Work/JPohlmann/HW2/.idea/workspace.xml new file mode 100644 index 0000000..b500221 --- /dev/null +++ b/Student Work/JPohlmann/HW2/.idea/workspace.xml @@ -0,0 +1,536 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1523488060784 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + file://$PROJECT_DIR$/src/RomanTest.java + 59 + + + + file://$PROJECT_DIR$/src/RomanTest.java + 2 + + + + file://$PROJECT_DIR$/src/RomanTest.java + 4 + + + + file://$PROJECT_DIR$/src/RomanTest.java + 8 + + + + file://$PROJECT_DIR$/src/RomanTest.java + 10 + + + + file://$PROJECT_DIR$/src/RomanTest.java + 17 + + + + file://$PROJECT_DIR$/src/RomanTest.java + 24 + + + + file://$PROJECT_DIR$/src/RomanTest.java + 23 + + + + file://$PROJECT_DIR$/src/RomanTest.java + 28 + + + + file://$PROJECT_DIR$/src/RomanTest.java + 32 + + + + file://$PROJECT_DIR$/src/RomanTest.java + 38 + + + + file://$PROJECT_DIR$/src/RomanTest.java + 43 + + + + file://$PROJECT_DIR$/src/RomanNumeralConverter.java + 91 + + + + file://$PROJECT_DIR$/src/RomanNumeralConverter.java + 87 + + + + file://$PROJECT_DIR$/src/RomanNumeralConverter.java + 92 + + + + file://$PROJECT_DIR$/src/RomanNumeralConverter.java + 127 + + + + file://$PROJECT_DIR$/src/RomanNumeralConverter.java + 133 + + + + file://$PROJECT_DIR$/src/RomanNumeralConverter.java + 20 + + + + file://$PROJECT_DIR$/src/RomanNumeralConverter.java + 103 + + + + file://$PROJECT_DIR$/src/RomanNumeralConverter.java + 26 + + + + file://$PROJECT_DIR$/src/RomanNumeralConverter.java + 28 + + + + file://$PROJECT_DIR$/src/RomanNumeralConverter.java + 34 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Student Work/JPohlmann/HW2/HW2.iml b/Student Work/JPohlmann/HW2/HW2.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/Student Work/JPohlmann/HW2/HW2.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Student Work/JPohlmann/HW2/out/production/HW2/Problem2Texting$1.class b/Student Work/JPohlmann/HW2/out/production/HW2/Problem2Texting$1.class new file mode 100644 index 0000000..9260b21 Binary files /dev/null and b/Student Work/JPohlmann/HW2/out/production/HW2/Problem2Texting$1.class differ diff --git a/Student Work/JPohlmann/HW2/out/production/HW2/Problem2Texting.class b/Student Work/JPohlmann/HW2/out/production/HW2/Problem2Texting.class new file mode 100644 index 0000000..a63781d Binary files /dev/null and b/Student Work/JPohlmann/HW2/out/production/HW2/Problem2Texting.class differ diff --git a/Student Work/JPohlmann/HW2/out/production/HW2/RomanNumeralConverter$1.class b/Student Work/JPohlmann/HW2/out/production/HW2/RomanNumeralConverter$1.class new file mode 100644 index 0000000..d13676d Binary files /dev/null and b/Student Work/JPohlmann/HW2/out/production/HW2/RomanNumeralConverter$1.class differ diff --git a/Student Work/JPohlmann/HW2/out/production/HW2/RomanNumeralConverter.class b/Student Work/JPohlmann/HW2/out/production/HW2/RomanNumeralConverter.class new file mode 100644 index 0000000..f06bd93 Binary files /dev/null and b/Student Work/JPohlmann/HW2/out/production/HW2/RomanNumeralConverter.class differ diff --git a/Student Work/JPohlmann/HW2/out/production/HW2/RomanTest.class b/Student Work/JPohlmann/HW2/out/production/HW2/RomanTest.class new file mode 100644 index 0000000..9239d61 Binary files /dev/null and b/Student Work/JPohlmann/HW2/out/production/HW2/RomanTest.class differ diff --git a/Student Work/JPohlmann/HW2/out/production/HW2/SentenceBox.class b/Student Work/JPohlmann/HW2/out/production/HW2/SentenceBox.class new file mode 100644 index 0000000..864f3c4 Binary files /dev/null and b/Student Work/JPohlmann/HW2/out/production/HW2/SentenceBox.class differ diff --git a/Student Work/JPohlmann/HW2/src/Problem2Texting.java b/Student Work/JPohlmann/HW2/src/Problem2Texting.java new file mode 100644 index 0000000..05c62cb --- /dev/null +++ b/Student Work/JPohlmann/HW2/src/Problem2Texting.java @@ -0,0 +1,48 @@ +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Scanner; + +import static javax.swing.UIManager.put; + +public class Problem2Texting { + + + public static void main(String[] args) { + System.out.println("What is the number?"); + Scanner sysIn= new Scanner(System.in); + String input=sysIn.next(); + System.out.println(letterCombinations(input)); + } + + public static ArrayList letterCombinations(String digits) { + ArrayList result = new ArrayList(); + ArrayList preresult = new ArrayList(); + result.add(""); + + for (int i = 0; i < digits.length(); i++) { + for (String str : result) { + String letters = map.get(digits.charAt(i)); + for (int j = 0; j < letters.length(); j++) + preresult.add(str + letters.charAt(j)); + } + result = preresult; + preresult = new ArrayList(); + } + return result; + } + + static final HashMap map = new HashMap() { + { + put('2', "abc"); + put('3', "def"); + put('4', "ghi"); + put('5', "jkl"); + put('6', "mno"); + put('7', "prs"); + put('8', "tuv"); + put('9', "wxy"); + put('1'," "); + put('0'," "); + } + }; +} diff --git a/Student Work/JPohlmann/HW2/src/RomanNumeralConverter.java b/Student Work/JPohlmann/HW2/src/RomanNumeralConverter.java new file mode 100644 index 0000000..9ebc29b --- /dev/null +++ b/Student Work/JPohlmann/HW2/src/RomanNumeralConverter.java @@ -0,0 +1,153 @@ +import java.util.HashMap; +import java.util.Scanner; + +public class RomanNumeralConverter { + public static void main(java.lang.String args[]) { + System.out.println("Insert Roman Numeral"); + Scanner sysIn = new Scanner(System.in); + String romanNumber = sysIn.next(); + if (romanToInteger(romanNumber) == 0.1) { + System.out.println("Error: Not all characters are valid Roman Numerals."); + } + else if(romanToInteger(romanNumber)==0.2){ + System.out.println( "Error: Auxiliary symbols are not allowed to be subtracted in Roman Numerals."); + } + else if(romanToInteger(romanNumber)==0.3){ + System.out.println("Error: Subtraction of consecutive characters is not allowed."); + } + else if(romanToInteger(romanNumber)==0.4){ + System.out.println("Error: The value of symbols to be added must not increase as we work through the Roman Numeral."); + } + else{ + System.out.println(romanToInteger(romanNumber)); + } + } + public static double romanToInteger(String romanNumber) { + double decimal = 0; + double lastNumber = 0; + String romanNumeral = romanNumber.toUpperCase(); + char[] numeralList= new char[romanNumeral.length()]; + + for (int x = romanNumeral.length() - 1; x >= 0 ; x--) { + numeralList[x]= romanNumeral.charAt(x); + char convertToDecimal = romanNumeral.charAt(x); + + if(convertToDecimal == 'M'||convertToDecimal=='D'||convertToDecimal=='C'||convertToDecimal=='L'||convertToDecimal=='X'||convertToDecimal=='V'||convertToDecimal=='I') { + + switch (convertToDecimal) { + case 'M': + decimal = numeralMath(1000, lastNumber, decimal); + lastNumber = 1000; + break; + + case 'D': + decimal = numeralMath(500, lastNumber, decimal); + lastNumber = 500; + break; + + case 'C': + decimal = numeralMath(100, lastNumber, decimal); + lastNumber = 100; + break; + + case 'L': + decimal = numeralMath(50, lastNumber, decimal); + lastNumber = 50; + break; + + case 'X': + decimal = numeralMath(10, lastNumber, decimal); + lastNumber = 10; + break; + + case 'V': + decimal = numeralMath(5, lastNumber, decimal); + lastNumber = 5; + break; + + case 'I': + decimal = numeralMath(1, lastNumber, decimal); + lastNumber = 1; + break; + } + } + else{ + return 0.1; + } + if(decimal==0.2) { + return 0.2; + } + + } + if(checkSubtract(numeralList)==true){ + + } + else{ + return 0.3; + } + for(int x =0; x < (numeralList.length-2);x++){ + if(numeralList.length>2) { + + + if (checkPosition.get(numeralList[x]) < (checkPosition.get(numeralList[x + 2]) - checkPosition.get(numeralList[x + 1]))) { + return 0.4; + } + } + + + } + return decimal; + } + + public static boolean checkSubtract(char[] numeralList){ + for(int x=0;x< numeralList.length;x++){ + if(numeralList[x]=='I'&&numeralList[x+1]=='V'&&numeralList[x+2]=='X'){ + return false; + } + else if(numeralList[x]=='V'&&numeralList[x+1]=='X'&&numeralList[x+2]=='L'){ + return false; + } + else if(numeralList[x]=='X'&&numeralList[x+1]=='L'&&numeralList[x+2]=='C'){ + return false; + } + else if(numeralList[x]=='L'&&numeralList[x+1]=='C'&&numeralList[x+2]=='D'){ + return false; + } + else if(numeralList[x]=='C'&&numeralList[x+1]=='D'&&numeralList[x+2]=='M'){ + return false; + } + else{ + return true; + } + } + return true; + +} + static final HashMap checkPosition = new HashMap() { + { + put('M', 1000); + put('D', 500); + put('C', 100); + put('L', 50); + put('X', 10); + put('V', 5); + put('I', 1); + put(' ',0); + + } + }; + + public static double numeralMath(double decimal, double lastNumber, double lastDecimal) { + if (lastNumber > decimal&& (decimal==5||decimal==50||decimal==500)) { + return 0.2; + } + else if(lastNumber > decimal){ + return lastDecimal - decimal; + } + else { + return lastDecimal + decimal; + } + } + + +} diff --git a/Student Work/JPohlmann/HW2/src/SentenceBox.java b/Student Work/JPohlmann/HW2/src/SentenceBox.java new file mode 100644 index 0000000..74598bd --- /dev/null +++ b/Student Work/JPohlmann/HW2/src/SentenceBox.java @@ -0,0 +1,41 @@ +import java.util.Scanner; + +public class SentenceBox { + public static void main(String[]args){ + System.out.println("How many words are in the sentence?"); + Scanner sysIn= new Scanner(System.in); + int input= sysIn.nextInt(); + String[] list= new String[input]; + for(int k=0; k longest.length()){ + longest = tempList; + } + + } + int maxNum= longest.length(); + String dashes=""; + for(int g=0; g0;spaceNum--){ + spaceDisplay+=" "; + } + System.out.println("|"+ list[h]+ spaceDisplay+"|"); + spaceDisplay=""; + } + System.out.print("+"+ dashes+"+"); + } +} diff --git a/Student Work/Jackson_Maschman_HW2/HW2_1 b/Student Work/Jackson_Maschman_HW2/HW2_1 new file mode 100644 index 0000000..6296068 --- /dev/null +++ b/Student Work/Jackson_Maschman_HW2/HW2_1 @@ -0,0 +1,52 @@ +import java.util.Scanner; +public class HW2_1 { + + public static void main(String[] args) + { + Scanner scan = new Scanner(System.in); + StringArray a; + a = new StringArray(); + //Brings each sentence into an array + while(scan.hasNext()) + { + a.add(scan.next()); + } + + //Checks for largest word + + int Word = a.array[0].length(); + + for(int x = 0; x < a.size; x++) + { + if(Word < a.array[x].length()) + { + Word = a.array[x].length(); + } + } + + String Sentence1 = "+--"; + + for(int b = 0; b < Word; b++) + { + Sentence1 = Sentence1 + "-"; + } + + Sentence1 = Sentence1 + "+"; + + System.out.println(Sentence1); + + for(int y = 0; y < a.size; y++) + { + String Sentence2 = "| "; + Sentence2 = Sentence2 + a.array[y]; + for(int d = 0; d < (Word - a.array[y].length()); d++) + { + Sentence2 = Sentence2 + " "; + } + Sentence2 = Sentence2 + " |"; + System.out.println(Sentence2); + } + System.out.println(Sentence1); + + } +} diff --git a/Student Work/PiiaMT/.idea/.name b/Student Work/PiiaMT/.idea/.name new file mode 100644 index 0000000..b15892b --- /dev/null +++ b/Student Work/PiiaMT/.idea/.name @@ -0,0 +1 @@ +PiiaMT_HW2 \ No newline at end of file diff --git a/Student Work/PiiaMT/.idea/misc.xml b/Student Work/PiiaMT/.idea/misc.xml new file mode 100644 index 0000000..8e8843c --- /dev/null +++ b/Student Work/PiiaMT/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Student Work/PiiaMT/.idea/modules.xml b/Student Work/PiiaMT/.idea/modules.xml new file mode 100644 index 0000000..cb8dfb2 --- /dev/null +++ b/Student Work/PiiaMT/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Student Work/PiiaMT/.idea/workspace.xml b/Student Work/PiiaMT/.idea/workspace.xml new file mode 100644 index 0000000..39f5498 --- /dev/null +++ b/Student Work/PiiaMT/.idea/workspace.xml @@ -0,0 +1,450 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1523994702952 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Student Work/dburrigh/HW2.iml b/Student Work/dburrigh/HW2.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/Student Work/dburrigh/HW2.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Student Work/dburrigh/Thought Process for Problems 1, 2, and 3.pdf b/Student Work/dburrigh/Thought Process for Problems 1, 2, and 3.pdf new file mode 100644 index 0000000..0e5a07f Binary files /dev/null and b/Student Work/dburrigh/Thought Process for Problems 1, 2, and 3.pdf differ diff --git a/Student Work/dburrigh/dburrigh.iml b/Student Work/dburrigh/dburrigh.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/Student Work/dburrigh/dburrigh.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Student Work/dburrigh/out/production/dburrigh/.idea/misc.xml b/Student Work/dburrigh/out/production/dburrigh/.idea/misc.xml new file mode 100644 index 0000000..99ae653 --- /dev/null +++ b/Student Work/dburrigh/out/production/dburrigh/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Student Work/dburrigh/out/production/dburrigh/.idea/modules.xml b/Student Work/dburrigh/out/production/dburrigh/.idea/modules.xml new file mode 100644 index 0000000..f669a0e --- /dev/null +++ b/Student Work/dburrigh/out/production/dburrigh/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Student Work/dburrigh/out/production/dburrigh/.idea/src.iml b/Student Work/dburrigh/out/production/dburrigh/.idea/src.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/Student Work/dburrigh/out/production/dburrigh/.idea/src.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/Student Work/dburrigh/out/production/dburrigh/.idea/workspace.xml b/Student Work/dburrigh/out/production/dburrigh/.idea/workspace.xml new file mode 100644 index 0000000..60eb4e4 --- /dev/null +++ b/Student Work/dburrigh/out/production/dburrigh/.idea/workspace.xml @@ -0,0 +1,260 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1524520339519 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1.8 + + + + + + + + \ No newline at end of file diff --git a/Student Work/dburrigh/src/Problem1.java b/Student Work/dburrigh/src/Problem1.java new file mode 100644 index 0000000..f22f312 --- /dev/null +++ b/Student Work/dburrigh/src/Problem1.java @@ -0,0 +1,48 @@ +import java.util.Scanner; + +public class Problem1 { + + public static void main(String[] args) { + Scanner scan = new Scanner(System.in); + String Sentence = scan.nextLine(); + String[] wordy = Sentence.split(" "); + Problem1.Sentence(wordy); + } + + private static int LongestWord(String[] Sentence) //Want to find longest word + { + int LongestWord = 0; + for(int w = 0; w < Sentence.length; w++) //w = Word of Sentence + { + if(Sentence[w].length()>LongestWord) + { + LongestWord = Sentence[w].length(); + } + + } + return LongestWord; + } + + public static void Sentence(String[] LongWord) { + System.out.print("+"); + int n = Problem1.LongestWord(LongWord); + for (int i = 0; i < n + 2; i++) { + System.out.print("-"); + } + System.out.println("+"); + for(int i = 0; i < LongWord.length; i++) { + System.out.print("| " + LongWord[i]); + for(int j = 0; j <= n - LongWord[i].length(); j++) + { + System.out.print(" "); + + } + System.out.println("|"); + } + System.out.print("+"); + for (int i = 0; i < n + 2; i++) { + System.out.print("-"); + } + System.out.print("+"); + } + } diff --git a/Student Work/dburrigh/src/Problem2.java b/Student Work/dburrigh/src/Problem2.java new file mode 100644 index 0000000..7105879 --- /dev/null +++ b/Student Work/dburrigh/src/Problem2.java @@ -0,0 +1,36 @@ +import java.util.Scanner; + +public class Problem2 { + + public static void main(String[] args) + { + Scanner scan = new Scanner(System.in); + String PN = scan.nextLine(); + int PhoneNumber = PN.length(); + int[] numbers = new int[PhoneNumber]; + + int x = 0; + while(x SmallestAdd) { + System.out.println("Error: The value of symbols to be added must not increase as we work through the Roman Numeral"); + break; + } + result = result + Roman[a]; + return result; + } + if (Roman[a] >= Roman[a + 1]) { + if (Roman[a] > SmallestAdd) { + System.out.println("Error: The value of symbols to be added must not increase as we work through the Roman Numeral"); + break; + } else { + result = result + Roman[a]; + subcount = 0; + SmallestAdd = Roman[a]; + } + } else { + if (Roman[a] == 5 || Roman[a] == 50 || Roman[a] == 500) { + System.out.println("Error: Auxiliary symbols are not allowed to be subtracted in Roman Numerals"); + break; + } + subcount++; + if (subcount >= 2) { + System.out.println("Error: Subtraction of consecutive characters is not allowed"); + break; + } + result = result - Roman[a]; + } + + } + result = result + Roman[Roman.length - 1]; + + //this is the "algorithm" that will add/subtract the letters to Convert the Roman Numeral to an integer + return result; +} + + public static void main(String[] args) { + Scanner scan = new Scanner(System.in); + System.out.println("Enter a Roman Numeral"); + String RomanNumeral = scan.nextLine(); + System.out.println("The Roman Numeral you entered is " + Problem3.Convert(RomanNumeral)); + } +}