├── Calendar.pdf ├── HW1.pdf ├── HW2.pdf ├── HW3.pdf ├── Programs ├── Add.java ├── BMI.java ├── Currency.java ├── Docs │ ├── Currency.docx │ ├── EnterPIN.docx │ ├── FlipCoin.docx │ ├── LeapYear.docx │ ├── Magic8Ball.docx │ ├── Quadratic.docx │ ├── Quiz.docx │ ├── RockPaperScissorsLizardSpock.docx │ ├── SpaceBoxer.docx │ └── pH.docx ├── EnterPIN.java ├── FlipCoin.java ├── HelloWorld.java ├── Initials.java ├── LeapYear.java ├── Pattern.java ├── Quadratic.java ├── Quiz.java ├── SpaceBoxer.java ├── Temperature.java └── pH.java ├── Projects ├── BWT.java ├── Magic8Ball.java └── RockPaperScissorsLizardSpock.java ├── README.md ├── Slides ├── Lecture1.pdf ├── Lecture2.pdf ├── Lecture3.pdf ├── Lecture4.pdf └── Lecture5.pdf ├── Speed1.pdf ├── Syllabus.pdf ├── Textbook ├── Chapter 1. The Way of the Program.pdf ├── Chapter 2. Variables and Operators.pdf ├── Chapter 3. Input and Output.pdf ├── Chapter 4. Void Methods.pdf ├── Chapter 5. Conditionals and Logic.pdf ├── Chapter 7. Loops.pdf └── Chapter 8. Arrays.pdf ├── granit.jpg ├── logo.png ├── ratemyprofessors.png └── yelp.jpg /Calendar.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonnynomnom/CMP-167-Programming-Methods-I/90c8cc5a602b7e9d2b1d181c5a82bcb00c430591/Calendar.pdf -------------------------------------------------------------------------------- /HW1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonnynomnom/CMP-167-Programming-Methods-I/90c8cc5a602b7e9d2b1d181c5a82bcb00c430591/HW1.pdf -------------------------------------------------------------------------------- /HW2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonnynomnom/CMP-167-Programming-Methods-I/90c8cc5a602b7e9d2b1d181c5a82bcb00c430591/HW2.pdf -------------------------------------------------------------------------------- /HW3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonnynomnom/CMP-167-Programming-Methods-I/90c8cc5a602b7e9d2b1d181c5a82bcb00c430591/HW3.pdf -------------------------------------------------------------------------------- /Programs/Add.java: -------------------------------------------------------------------------------- 1 | /* Bryant Henning */ 2 | /* Fun Fact: I play Eve Online. */ 3 | 4 | import java.util.Scanner; 5 | 6 | public class Add { 7 | 8 | public static void main(String[] args) { 9 | 10 | Scanner input = new Scanner(System.in); 11 | 12 | int num, total = 0; 13 | 14 | System.out.print("Number: "); 15 | num = input.nextInt(); 16 | 17 | System.out.println(); 18 | 19 | for (int x = 1; x <= num; x++) 20 | { 21 | 22 | System.out.print(x + " "); 23 | 24 | total = total + x; 25 | 26 | } 27 | 28 | System.out.println("\nThe sum is " + total + "."); 29 | 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /Programs/BMI.java: -------------------------------------------------------------------------------- 1 | // Sonny Li 2 | // CMP 167: Programming Methods I 3 | 4 | import java.util.Scanner; 5 | 6 | public class BMI { 7 | 8 | public static void main(String[] args) { 9 | 10 | double height, weight, bmi; 11 | 12 | Scanner in = new Scanner(System.in); 13 | 14 | System.out.print("Type in your height (m): "); 15 | height = in.nextDouble(); 16 | 17 | System.out.print("Type in your weight (kg): "); 18 | weight = in.nextDouble(); 19 | 20 | bmi = weight / (height * height); 21 | 22 | System.out.printf("Your BMI is %.1f\n", bmi); 23 | 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /Programs/Currency.java: -------------------------------------------------------------------------------- 1 | // Sonny Li 2 | // CMP 167: Programming Methods I 3 | 4 | import java.util.Scanner; 5 | 6 | public class Currency { 7 | 8 | public static void main(String[] args) { 9 | 10 | double p, q, c; 11 | double total; 12 | 13 | Scanner in = new Scanner(System.in); 14 | 15 | System.out.print("Enter number of Mexican Pesos: "); 16 | p = in.nextDouble(); 17 | 18 | System.out.print("Enter number of Guatemalan Quetzals: "); 19 | q = in.nextDouble(); 20 | 21 | System.out.print("Enter number of Salvadoran Colons: "); 22 | c = in.nextDouble(); 23 | 24 | total = p * 0.0544 + q * 0.1305 + c * 0.1144; 25 | 26 | System.out.printf("US Dollars = $%.2f\n", total); 27 | 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /Programs/Docs/Currency.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonnynomnom/CMP-167-Programming-Methods-I/90c8cc5a602b7e9d2b1d181c5a82bcb00c430591/Programs/Docs/Currency.docx -------------------------------------------------------------------------------- /Programs/Docs/EnterPIN.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonnynomnom/CMP-167-Programming-Methods-I/90c8cc5a602b7e9d2b1d181c5a82bcb00c430591/Programs/Docs/EnterPIN.docx -------------------------------------------------------------------------------- /Programs/Docs/FlipCoin.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonnynomnom/CMP-167-Programming-Methods-I/90c8cc5a602b7e9d2b1d181c5a82bcb00c430591/Programs/Docs/FlipCoin.docx -------------------------------------------------------------------------------- /Programs/Docs/LeapYear.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonnynomnom/CMP-167-Programming-Methods-I/90c8cc5a602b7e9d2b1d181c5a82bcb00c430591/Programs/Docs/LeapYear.docx -------------------------------------------------------------------------------- /Programs/Docs/Magic8Ball.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonnynomnom/CMP-167-Programming-Methods-I/90c8cc5a602b7e9d2b1d181c5a82bcb00c430591/Programs/Docs/Magic8Ball.docx -------------------------------------------------------------------------------- /Programs/Docs/Quadratic.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonnynomnom/CMP-167-Programming-Methods-I/90c8cc5a602b7e9d2b1d181c5a82bcb00c430591/Programs/Docs/Quadratic.docx -------------------------------------------------------------------------------- /Programs/Docs/Quiz.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonnynomnom/CMP-167-Programming-Methods-I/90c8cc5a602b7e9d2b1d181c5a82bcb00c430591/Programs/Docs/Quiz.docx -------------------------------------------------------------------------------- /Programs/Docs/RockPaperScissorsLizardSpock.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonnynomnom/CMP-167-Programming-Methods-I/90c8cc5a602b7e9d2b1d181c5a82bcb00c430591/Programs/Docs/RockPaperScissorsLizardSpock.docx -------------------------------------------------------------------------------- /Programs/Docs/SpaceBoxer.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonnynomnom/CMP-167-Programming-Methods-I/90c8cc5a602b7e9d2b1d181c5a82bcb00c430591/Programs/Docs/SpaceBoxer.docx -------------------------------------------------------------------------------- /Programs/Docs/pH.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonnynomnom/CMP-167-Programming-Methods-I/90c8cc5a602b7e9d2b1d181c5a82bcb00c430591/Programs/Docs/pH.docx -------------------------------------------------------------------------------- /Programs/EnterPIN.java: -------------------------------------------------------------------------------- 1 | // Sonny Li 2 | // CMP 167: Programming Methods I 3 | 4 | import java.util.Scanner; 5 | 6 | public class EnterPIN { 7 | 8 | public static void main(String[] args) { 9 | 10 | Scanner keyboard = new Scanner(System.in); 11 | int pin = 12345; 12 | 13 | System.out.println("============================="); 14 | System.out.println("WELCOME TO THE BANK OF LEHMAN"); 15 | System.out.println("=============================\n"); 16 | 17 | System.out.print("Enter your PIN: "); 18 | 19 | int entry = keyboard.nextInt(); 20 | 21 | while (entry != pin) 22 | { 23 | 24 | System.out.println("\nIncorrect. Please try again."); 25 | System.out.print("Enter your PIN: "); 26 | 27 | entry = keyboard.nextInt(); 28 | 29 | } 30 | 31 | System.out.println("\nPIN accepted. You now have access to your account."); 32 | 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /Programs/FlipCoin.java: -------------------------------------------------------------------------------- 1 | // Sonny Li 2 | // CMP 167: Programming Methods I 3 | 4 | public class FlipCoin { 5 | 6 | public static void main(String[] args) { 7 | 8 | if (Math.random() < 0.5) 9 | { 10 | System.out.println("Heads"); 11 | } 12 | else 13 | { 14 | System.out.println("Tails"); 15 | } 16 | 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /Programs/HelloWorld.java: -------------------------------------------------------------------------------- 1 | // Sonny Li 2 | // CMP 167: Programming Methods I 3 | 4 | public class HelloWorld { 5 | 6 | public static void main(String[] args) { 7 | 8 | System.out.println("Hello World!"); 9 | 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /Programs/Initials.java: -------------------------------------------------------------------------------- 1 | // Sonny Li 2 | // CMP 167: Programming Methods I 3 | 4 | public class Initials { 5 | 6 | public static void main(String[] args) { 7 | 8 | System.out.println(" SSS L "); 9 | System.out.println("S S L "); 10 | System.out.println("S L "); 11 | System.out.println(" SSS L "); 12 | System.out.println(" S L "); 13 | System.out.println("S S L "); 14 | System.out.println(" SSS LLLLL "); 15 | 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /Programs/LeapYear.java: -------------------------------------------------------------------------------- 1 | // Sonny Li 2 | // CMP 167: Programming Methods I 3 | 4 | import java.util.Scanner; 5 | 6 | public class LeapYear { 7 | 8 | public static void main(String[] args) { 9 | 10 | Scanner in = new Scanner(System.in); 11 | 12 | System.out.print("Enter month: "); 13 | int m = in.nextInt(); 14 | 15 | System.out.print("Enter day: "); 16 | int d = in.nextInt(); 17 | 18 | System.out.print("Enter year: "); 19 | int y = in.nextInt(); 20 | 21 | System.out.println(); 22 | 23 | if (m < 1 || m > 12 || d < 1 || d > 31 || y < 1000 || y > 9999) 24 | { 25 | System.out.println("\nInvalid entry."); 26 | } 27 | 28 | else if (y % 4 == 0 && y % 100 != 0 || y % 400 == 0) 29 | { 30 | System.out.println(m +"/"+ d + "/" + y + " falls on a leap year."); 31 | } 32 | 33 | else 34 | { 35 | System.out.println(m + "/" + d +"/" + y + " doesn't fall on a leap year."); 36 | } 37 | 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /Programs/Pattern.java: -------------------------------------------------------------------------------- 1 | // Sonny Li 2 | // CMP 167: Programming Methods I 3 | 4 | public class Pattern { 5 | 6 | public static void main(String[] args) { 7 | 8 | System.out.println(" 1"); 9 | System.out.println(" 2 3"); 10 | System.out.println(" 4 5 6"); 11 | System.out.println("7 8 9 10"); 12 | 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /Programs/Quadratic.java: -------------------------------------------------------------------------------- 1 | // Sonny Li 2 | // CMP 167: Programming Methods I 3 | 4 | import java.util.Scanner; 5 | 6 | public class Quadratic { 7 | 8 | public static void main(String[] args) { 9 | 10 | double a, b, c; 11 | double root1, root2; 12 | 13 | Scanner in = new Scanner(System.in); 14 | 15 | System.out.print("Enter a: "); 16 | a = in.nextDouble(); 17 | 18 | System.out.print("Enter b: "); 19 | b = in.nextDouble(); 20 | 21 | System.out.print("Enter c: "); 22 | c = in.nextDouble(); 23 | 24 | root1 = (-b + Math.sqrt(b*b - 4*a*c)) / (2*a); 25 | root2 = (-b - Math.sqrt(b*b - 4*a*c)) / (2*a); 26 | 27 | System.out.println("Root 1 is " + root1); 28 | System.out.println("Root 2 is " + root2); 29 | 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /Programs/Quiz.java: -------------------------------------------------------------------------------- 1 | // Sonny Li 2 | // CMP 167: Programming Methods I 3 | 4 | import java.util.Scanner; 5 | 6 | public class Quiz { 7 | 8 | public static void main(String[] args) { 9 | 10 | Scanner in = new Scanner(System.in); 11 | 12 | int answer1, answer2, answer3; 13 | int score = 0; 14 | 15 | System.out.print("Are you ready for a quiz? "); 16 | 17 | in.nextLine(); 18 | 19 | System.out.println("Okay, here it comes!\n"); 20 | 21 | // ============ Question 1 ============ 22 | 23 | System.out.println("Q1) What is the capital of Alaska?"); 24 | System.out.println(" 1) Melbourne"); 25 | System.out.println(" 2) Anchorage"); 26 | System.out.println(" 3) Juneau\n"); 27 | 28 | answer1 = in.nextInt(); 29 | 30 | if (answer1 == 3) 31 | { 32 | System.out.println("\nThat's right!\n"); 33 | score++; 34 | } 35 | else 36 | { 37 | System.out.println("\nThat's wrong!\n"); 38 | } 39 | 40 | // ============ Question 2 ============ 41 | 42 | System.out.println("Q2) Can you store the value \"cat\" in a variable of type int?"); 43 | System.out.println(" 1) Yes"); 44 | System.out.println(" 2) No\n"); 45 | 46 | answer2 = in.nextInt(); 47 | 48 | if (answer2 == 2) 49 | { 50 | System.out.println("\nGood job!\n"); 51 | score++; 52 | } 53 | else 54 | { 55 | System.out.println("\nSorry, \"cat\" is a string. ints can only store numbers.\n"); 56 | } 57 | 58 | // ============ Question 3 ============ 59 | 60 | System.out.println("Q3) What is the result of 9+6/3"); 61 | System.out.println(" 1) 5"); 62 | System.out.println(" 2) 11"); 63 | System.out.println(" 3) 15/3\n"); 64 | 65 | answer3 = in.nextInt(); 66 | 67 | if (answer3 == 2) 68 | { 69 | System.out.println("\nThat's correct!\n"); 70 | score++; 71 | } 72 | else 73 | { 74 | System.out.println("\nThat's incorrect!\n"); 75 | } 76 | 77 | // =============== OVER =============== 78 | 79 | System.out.println("Overall, you got " + score + " out of 3 correct."); 80 | System.out.println("Thanks for playing!"); 81 | 82 | } 83 | 84 | } -------------------------------------------------------------------------------- /Programs/SpaceBoxer.java: -------------------------------------------------------------------------------- 1 | // Sonny Li 2 | // CMP 167: Programming Methods I 3 | 4 | import java.util.Scanner; 5 | 6 | public class SpaceBoxer { 7 | 8 | public static void main(String[] args) { 9 | 10 | Scanner in = new Scanner(System.in); 11 | 12 | double weight; 13 | int x; 14 | 15 | System.out.print("Please enter your current earth weight: "); 16 | weight = in.nextDouble(); 17 | 18 | System.out.println("\nI have information for the following planets:"); 19 | System.out.println(" 1. Venus 2. Mars 3. Jupiter"); 20 | System.out.println(" 4. Saturn 5. Uranus 6. Neptune\n"); 21 | 22 | System.out.print("Which planet are you visiting? " ); 23 | x = in.nextInt(); 24 | 25 | if (x == 1) 26 | { 27 | weight = weight * 0.78; 28 | } 29 | else if (x == 2) 30 | { 31 | weight = weight * 0.39; 32 | } 33 | else if (x == 3) 34 | { 35 | weight = weight * 2.65; 36 | } 37 | else if (x == 4) 38 | { 39 | weight = weight * 1.17; 40 | } 41 | else if (x == 5) 42 | { 43 | weight = weight * 1.05; 44 | } 45 | else if (x == 6) 46 | { 47 | weight = weight * 1.23; 48 | } 49 | 50 | System.out.printf("\nYou weight would be %.2f pounds on that planet.\n", weight); 51 | 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /Programs/Temperature.java: -------------------------------------------------------------------------------- 1 | // Sonny Li 2 | // CMP 167: Programming Methods I 3 | 4 | import java.util.Scanner; 5 | 6 | public class Temperature { 7 | 8 | public static void main(String[] args) { 9 | 10 | double tempf; 11 | double tempc; 12 | 13 | Scanner in = new Scanner(System.in); 14 | 15 | System.out.print("Enter temp in Fahrenheit: "); 16 | tempf = in.nextDouble(); 17 | 18 | tempc = (tempf - 32) * 5 / 9; 19 | 20 | System.out.printf("The current temp is %.1f degrees Celsius.\n", tempc); 21 | 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /Programs/pH.java: -------------------------------------------------------------------------------- 1 | // Sonny Li 2 | // CMP 167: Programming Methods I 3 | 4 | import java.util.Scanner; 5 | 6 | public class pH { 7 | 8 | public static void main(String[] args) { 9 | 10 | Scanner in = new Scanner(System.in); 11 | 12 | double ph; 13 | 14 | System.out.print("Enter pH level (0-14): "); 15 | ph = in.nextDouble(); 16 | 17 | if (ph > 7) 18 | { 19 | System.out.println("Basic"); 20 | } 21 | else if (ph < 7) 22 | { 23 | System.out.println("Acidic"); 24 | } 25 | else 26 | { 27 | System.out.println("~Neutral~"); 28 | } 29 | 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /Projects/BWT.java: -------------------------------------------------------------------------------- 1 | // Granit Dedushi 2 | // CMP167 3 | // BWT 4 | 5 | import java.util.Scanner; 6 | import java.util.Arrays; 7 | import java.util.List; 8 | 9 | public class BWT 10 | { 11 | 12 | public static void main(String[] args) 13 | { 14 | 15 | Scanner in = new Scanner(System.in); 16 | System.out.println("Encrypt(Press 1) or Decrypt(Press 2) "); 17 | int startTest = in.nextInt(); 18 | 19 | in.nextLine(); // this is to offset empty entry when pulling next input 20 | 21 | // ********************* START OF ENCRYPTION CODE ********************* 22 | if (startTest == 1) 23 | { 24 | System.out.println("Enter something you would like to encrypt: "); 25 | String inString = in.nextLine(); 26 | System.out.println("Hello"); 27 | 28 | // creating a size value to use in array 29 | // size will be the amount of characters in the original input 30 | final int SIZE = inString.length(); 31 | 32 | // creates an array of strings, for every letter in input, there is a row in array 33 | String[] rotations = new String[SIZE]; 34 | // this is to take result from lastChars 35 | String result = ""; 36 | 37 | // generate the transfromation process and print first stage of transform 38 | genRotations(inString, rotations); 39 | System.out.println("Encryption process initializing:\n "); 40 | printStringArray(rotations, SIZE); 41 | 42 | // sorts the array of strings lexicographically and print the sorted array 43 | Arrays.sort(rotations); 44 | System.out.println("Initializing Mixer:\n"); 45 | printStringArray(rotations, SIZE); 46 | 47 | // take last character of each sorted string to get the final transformed string 48 | result = lastChars(rotations, SIZE); 49 | System.out.println("COPY DOWN EVERYTHING THAT IS IMMEDIATELY AFTER AND " + 50 | "BEFORE ARROWS (INCLUDING SPACES) \nDO NOT LOSE THE STRING OR KEY OR YOU WONT BE ABLE TO DECODE!"); 51 | System.out.println("-----------------------------------------------------------------------------"); 52 | System.out.println("YOUR FINAL STRING IS:----->" + result + "<-----"); 53 | // getting the key to original input 54 | findKey(inString, rotations); 55 | } 56 | 57 | // *********************** START OF DECRYPTION CODE *********************** 58 | else if (startTest == 2) 59 | { 60 | System.out.println("Enter encrypted string: "); 61 | String encString = in.nextLine(); 62 | System.out.println("Enter key value: "); 63 | int encKey = in.nextInt(); 64 | // input Validation, index key must be equal to or greater than 0 65 | while(encKey < 0) 66 | { 67 | System.out.println("Your index value must be positive, Enter Index Again."); 68 | encKey = in.nextInt(); 69 | } 70 | 71 | final int SIZE = encString.length(); 72 | 73 | // creates a new array of strings same size as encString 74 | String[] revRotations = new String[SIZE]; 75 | String result; 76 | 77 | // placeholder to remove null from decrypted string 78 | // this will make the sorted array into list which I will then print 79 | List remNull; 80 | 81 | // runs once for each stage 82 | for(int cycles = 0; cycles < encString.length(); cycles++) 83 | { 84 | moveFront(encString, revRotations); 85 | Arrays.sort(revRotations); 86 | remNull = Arrays.asList(revRotations); 87 | System.out.println("Stage " + (cycles+1) + "\n"); 88 | for (int i = 0; i < SIZE; i++) 89 | { 90 | String temporary = remNull.get(i); 91 | int temporaryInt = temporary.length()-4; 92 | temporary = temporary.substring(0, temporaryInt); 93 | System.out.println(temporary); 94 | } 95 | System.out.println(); 96 | } 97 | 98 | System.out.println("DECRYPTION COMPLETE! \n \nCHECK RESULTS BELOW"); 99 | System.out.println("| | | | | | | | | | \nV V V V V V V V V V"); 100 | // converting to list and then printing a certain item from list 101 | List decrypt = Arrays.asList(revRotations); 102 | String temp = decrypt.get(encKey); 103 | System.out.println("-----------------------------------------------------------------------------"); 104 | System.out.println("AT INDEX NUMBER: " + encKey + ""); 105 | System.out.println("THE DECRYPTED STRING: " + temp.substring(0, SIZE)); 106 | System.out.println("-----------------------------------------------------------------------------"); 107 | 108 | } 109 | else 110 | { 111 | System.out.println("Start me up again when you are ready to encrypt or decrypt."); 112 | } 113 | 114 | } 115 | 116 | // **************** START OF ENCRYPTION METHODS **************** 117 | 118 | /* move first letter of previous string to end. do this i(length of word) times. 119 | @param - source is the input string to start transform 120 | @param - s is string array that will store new transformed strings 121 | */ 122 | public static void genRotations(String source, String[] s) 123 | { 124 | s[0] = source; 125 | for (int i=1; i < source.length(); i++) 126 | { 127 | s[i] = s[i-1].substring(1) + s[i-1].charAt(0); 128 | } 129 | } 130 | 131 | /* print the string array to see transformation 132 | @param - s is string array that will be printed 133 | @param - SIZE is the number of rows you would like array to be 134 | */ 135 | public static void printStringArray(String[] s, int SIZE) 136 | { 137 | // start at 0 index to print all rows 138 | for (int i=0; i < SIZE; i++) 139 | { 140 | System.out.println(s[i]); 141 | } 142 | System.out.println(); 143 | } 144 | 145 | /* find the row that matches to original input so we can decode 146 | @param - s is the string you would like to find 147 | @param - a is the string array to search through 148 | */ 149 | public static void findKey(String s, String[] a) 150 | { 151 | int key; 152 | for (int i=0; i < s.length(); i++) 153 | { 154 | String match = a[i]; 155 | 156 | while (match == s) 157 | { 158 | key = i; 159 | System.out.println("YOUR INDEX KEY IS:----->" + key + "<-----"); 160 | System.out.println("----------------------------------" 161 | + "-------------------------------------------"); 162 | return; 163 | } 164 | } 165 | } 166 | 167 | /* takes last character of each row in final sorted array and creates a word with them 168 | @param - s is string array to search through 169 | @param - SIZE is the length of original string 170 | @return - result, which is a word made from last letter of each subsequent row 171 | */ 172 | public static String lastChars(String[] s, int SIZE) 173 | { 174 | String result = ""; 175 | for (int i=0; i < SIZE; i++) 176 | { 177 | result = result + s[i].charAt(SIZE-1); 178 | } 179 | return result; 180 | } 181 | 182 | // ****************** START OF DECRYPTION METHODS ****************** 183 | 184 | /*inputs the column letter of encString as the corresponding row in array 185 | @param - s is the encrypted string 186 | @param - a is the string array to form which will lead back to original transform 187 | */ 188 | public static void moveFront(String s, String[] a) 189 | { 190 | for (int i = 0; i < s.length(); i++) 191 | { 192 | a[i] = s.substring(i, i+1) + a[i]; 193 | } 194 | } 195 | } 196 | -------------------------------------------------------------------------------- /Projects/Magic8Ball.java: -------------------------------------------------------------------------------- 1 | // Ginell Rosario & Alex Mayi 2 | // Magic 8-Ball 3 | 4 | import java.util.Scanner; 5 | import java.util.Random; 6 | 7 | public class Magic8Ball { 8 | 9 | public static void main(String[] args) { 10 | 11 | Scanner in = new Scanner(System.in); 12 | Random r = new Random(); 13 | 14 | int choice = 1 + r.nextInt(14); 15 | 16 | String name, response = ""; 17 | 18 | System.out.println("My name is Derp. I am the Magic 8-Ball."); 19 | System.out.println("What's your name? "); 20 | name = in.nextLine(); 21 | 22 | System.out.println("\nDo you have a question for me, " + name + "? Ask away!"); 23 | in.nextLine(); 24 | 25 | if (choice == 1) { 26 | response = "#YAS"; 27 | } 28 | else if (choice == 2) { 29 | response = "Yes... yes... and YES"; 30 | } 31 | else if (choice == 3) { 32 | response = "The stars align. It is a definite yes."; 33 | } 34 | else if (choice == 4) { 35 | response = "Okie doke from me~"; 36 | } 37 | else if (choice == 5) { 38 | response = "Yeah, I think so."; 39 | } 40 | else if (choice == 6) { 41 | response = "Never in your life."; 42 | } 43 | else if (choice == 7) { 44 | response = "Well, let's just say you need to get out of there ASAP!"; 45 | } 46 | else if (choice == 8) { 47 | response = "Nope, I don't have a good feeling about this."; 48 | } 49 | else if (choice == 9) { 50 | response = "N A H"; 51 | } 52 | else if (choice == 10) { 53 | response = "Reply hazy, check back later."; 54 | } 55 | else if (choice == 11) { 56 | response = "One day it shall all become clear."; 57 | } 58 | else if (choice == 12) { 59 | response = "Oh no... you are not gonna like the answer."; 60 | } 61 | else if (choice == 13) { 62 | response = "Idk *_*"; 63 | } 64 | else if (choice == 14) { 65 | response = "Maaaybe, try again!"; 66 | } 67 | else { 68 | response = "8-BALL ERROR!"; 69 | } 70 | 71 | System.out.println("\nMAGIC 8-BALL SAYS: " + response); 72 | 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /Projects/RockPaperScissorsLizardSpock.java: -------------------------------------------------------------------------------- 1 | // Jeffrey Matthew & Justin Acosta 2 | // Rock Paper Scissors (The Big Bang Theory) 3 | // https://www.youtube.com/watch?v=cSLeBKT7-sM 4 | 5 | /* Hey there! This is the Big Bang Theory version of RPS, which includes Lizard and Spock. 6 | The idea came from Justin Acosta (teammate), and I was able to write the program. 7 | Feel free to make changes to the code. */ 8 | 9 | import java.util.Scanner; 10 | 11 | public class RockPaperScissorsLizardSpock { 12 | 13 | public static void main(String[] args) { 14 | 15 | Scanner in = new Scanner(System.in); 16 | 17 | String user_choice, computer_choice = null; 18 | int computer = (int) (Math.random() * 5 + 1); 19 | 20 | System.out.println("Welcome to Rock Paper Scissors: Big Bang Theory Edition!\n"); 21 | System.out.println("To play, you will need to type in the following choices:\n"); 22 | System.out.println(" -Rock -Paper -Scissors"); 23 | System.out.println(" -Lizard -Spock\n"); 24 | 25 | System.out.print("Enter your move: "); 26 | user_choice = in.nextLine(); 27 | 28 | if (computer == 1) 29 | computer_choice = "Rock"; 30 | 31 | if (computer == 2) 32 | computer_choice = "Paper"; 33 | 34 | if (computer == 3) 35 | computer_choice = "Scissors"; 36 | 37 | if (computer == 4) 38 | computer_choice = "Lizard"; 39 | 40 | if (computer == 5) 41 | computer_choice = "Spock"; 42 | 43 | System.out.println("\nComputer chose " + computer_choice + ".\n"); 44 | 45 | if (user_choice.equals("Rock")) { 46 | 47 | if (computer == 1) 48 | System.out.println("You tied!"); 49 | 50 | if (computer == 2) 51 | System.out.println("Paper has covered Rock. You lost!"); 52 | 53 | if (computer == 3) 54 | System.out.println("Rock crushes Scissors. You won!"); 55 | 56 | if (computer == 4) 57 | System.out.println("Rock crushes Lizard. You won!"); 58 | 59 | if (computer == 5) 60 | System.out.println("Rock has been vaporized by Spock. You lost!"); 61 | 62 | } 63 | 64 | if (user_choice.equals("Paper")) { 65 | 66 | if (computer == 1) 67 | System.out.println("Paper has covered Rock. You won!"); 68 | 69 | if (computer == 2) 70 | System.out.println("You tied!"); 71 | 72 | if (computer == 3) 73 | System.out.println("Paper has been cut by Scissors. You lost!"); 74 | 75 | if (computer == 4) 76 | System.out.println("Paper has been eaten by Lizard. You lost!"); 77 | 78 | if (computer == 5) 79 | System.out.println("Paper has disproved Spock. You won!"); 80 | 81 | } 82 | 83 | if (user_choice.equals("Scissors")) { 84 | 85 | if (computer == 1) 86 | System.out.println("Rock has crushed Scissors. You lost!"); 87 | 88 | if (computer == 2) 89 | System.out.println("Scissors has cut Paper. You won!"); 90 | 91 | if (computer == 3) 92 | System.out.println("You both tied!"); 93 | 94 | if (computer == 4) 95 | System.out.println("Scissors has killed Lizard. You won!"); 96 | 97 | if (computer == 5) 98 | System.out.println("Spock has smashed Scissors. You lost!"); 99 | 100 | } 101 | 102 | if (user_choice.equals("Lizard")) { 103 | 104 | if (computer == 1) 105 | System.out.println("Rock has crushed Lizard. You lost!"); 106 | 107 | if (computer == 2) 108 | System.out.println("Lizard has eaten Paper. You won!"); 109 | 110 | if (computer == 3) 111 | System.out.println("Lizard has been cut by Scissors. You lost!"); 112 | 113 | if (computer == 4) 114 | System.out.println("You have tied!"); 115 | 116 | if (computer == 5) 117 | System.out.println("Lizard has poisoned Spock. You won!"); 118 | 119 | } 120 | 121 | if (user_choice.equals("Spock")) { 122 | 123 | if (computer == 1) 124 | System.out.println("Rock has been vaporized by Spock. You won!"); 125 | 126 | if (computer == 2) 127 | System.out.println("Paper has disproved Spock. You lost!"); 128 | 129 | if (computer == 3) 130 | System.out.println("Spock smashes Scissors. You won!"); 131 | 132 | if (computer == 4) 133 | System.out.println("Lizard has poisoned Spock. You lost!"); 134 | 135 | if (computer == 5) 136 | System.out.println("You tied!"); 137 | 138 | } 139 | 140 | } 141 | 142 | } 143 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CMP 167: Programming Methods I # 2 | 3 | ![Lehman College][logo] 4 | 5 | [logo]: https://github.com/sonnynomnom/CMP-167-Programming-Methods-I/blob/master/logo.png "Lehman College 2017" 6 | 7 | **Instructor:** Songqiao "Sonny" Li (songqiao.li@lehman.cuny.edu) Rate My Professors 8 | 9 | **Section 1:** 11:00 am - 12:40 pm (MoWe) 10 | **Section 2:** 1:00 pm - 2:40 pm (TuTh) 11 | **Room:** Gillet 219 12 | 13 | **Office Hours:** TBA (Gillet 303) 14 | 15 | **TA:** Jocelyn Mercado (jocelyn.mercado@lc.cuny.edu) 16 | **TA:** Granit Dedushi (granit.dedushi@lc.cuny.edu) 17 |
18 |
19 | 20 | ## Course Description ## 21 | 22 | Structured computer programming using a modern high-level programming language: Java! Includes console I/O, data types, variables, control structures, arrays, function definitions and calls, parameter passing, functional decomposition, and an introduction to objects. Debugging techniques. 23 | 24 | ### Prerequisite ### 25 | 26 | MAT 104 or placement by the Department of Mathematics and Computer Science. 27 | 28 | ### Textbook ### 29 | 30 | [Think Java: How to Think Like a Computer Scientist](http://greenteapress.com/thinkjava6/thinkjava.pdf) (Allen B. Downey & Chris Mayfield) 31 | 32 | ### Piazza ### 33 | 34 | [www.piazza.com/lehman/fall2017/cmp167](http://piazza.com/lehman/fall2017/cmp167) 35 | 36 | ### Repl.it ### 37 | [https://www.repl.it/data/classrooms/share/fbb735156bb6f1cf4280d16c0b89161e](https://repl.it/data/classrooms/share/fbb735156bb6f1cf4280d16c0b89161e) 38 | 39 | ### Grading ### 40 | 41 | * Homework (6) 42 | * Quiz (2) 43 | * Midterm 44 | * Project 45 | * Final Exam 46 | 47 | ### Programs ### 48 | 49 | - [x] [`HelloWorld.java`](Programs/HelloWorld.java) 50 | - [x] [`Pattern.java`](Programs/Pattern.java) 51 | - [x] [`Initials.java`](Programs/Initials.java) 52 | 53 | - [x] [`Temperature.java`](Programs/Temperature.java) 54 | - [x] [`BMI.java`](Programs/BMI.java) 55 | - [x] [`Quadratic.java`](Programs/Quadratic.java) 56 | - [x] [`Currency.java`](Programs/Currency.java) **(HW1)** 57 | 58 | - [x] [`FlipCoin.java`](Programs/FlipCoin.java) 59 | - [x] [`pH.java`](Programs/pH.java) 60 | - [x] [`SpaceBoxer.java`](Programs/SpaceBoxer.java) 61 | - [x] [`Quiz.java`](Programs/Quiz.java) **(HW2)** 62 | 63 | - [ ] `Switch.java` 64 | - [x] [`LeapYear.java`](Programs/LeapYear.java) **(HW3)** 65 | 66 | - [ ] `YoungMoney.java` 67 | - [x] [`EnterPIN.java`](Programs/EnterPIN.java) 68 | - [x] `Guess1.java` 69 | - [x] `Guess2.java` 70 | - [ ] `TroubleMaker.java` 71 | - [ ] `FizzBuzz.java` **(HW4)** 72 | - [ ] `Add.java` 73 | 74 | - [ ] `Stars.java` 75 | - [ ] `Pattern1.java` 76 | - [ ] `Pattern2.java` 77 | 78 | - [ ] `Reverse.java` 79 | - [ ] `Armstrong.java` 80 | 81 | - [ ] `ComputingChange.java` 82 | 83 | - [ ] `StringDemo.java` 84 | 85 | - [ ] `BasicArray0.java` 86 | - [ ] `BasicArray1.java` 87 | 88 | - [ ] `LocatingLargest.java` 89 | - [ ] `Telephone.java` 90 | 91 | - [ ] `Area.java` 92 | - [ ] `HighScore.java` 93 | 94 | _*Update: Java tutoring is offered at the Math & Computer Science Learning Center (Gillet 222)_ 95 |
96 | 97 | ### Events ### 98 | 99 | * NSBE-SHPE CodeJam - March 25, 2017 ([Judge](https://credly.com/credit/13866597)) 100 |
101 | 102 | ### Mini Projects ### 103 | 104 | * [Rock Paper Scissors (Big Bang Theory)](Projects/RockPaperScissorsLizardSpock.java) - Jeffrey Matthew & Justin Acosta (Fall 2017) 105 | * [Derp the Magic 8-Ball](Projects/Magic8Ball.java) - Ginell Rosario & Alex Mayi (Fall 2017) 106 |
107 | 108 | ### Final Projects ### 109 | 110 | * [Burrows-Wheeler Transform](https://www.youtube.com/watch?v=h-J2_NIDvLw) - Granit Dedushi (Fall 2016) 111 |
112 | 113 | Drawing 114 | 115 | ## License 116 | Lehman College [Songqiao Li](https://instagram.com/sonnynomnom) 117 | -------------------------------------------------------------------------------- /Slides/Lecture1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonnynomnom/CMP-167-Programming-Methods-I/90c8cc5a602b7e9d2b1d181c5a82bcb00c430591/Slides/Lecture1.pdf -------------------------------------------------------------------------------- /Slides/Lecture2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonnynomnom/CMP-167-Programming-Methods-I/90c8cc5a602b7e9d2b1d181c5a82bcb00c430591/Slides/Lecture2.pdf -------------------------------------------------------------------------------- /Slides/Lecture3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonnynomnom/CMP-167-Programming-Methods-I/90c8cc5a602b7e9d2b1d181c5a82bcb00c430591/Slides/Lecture3.pdf -------------------------------------------------------------------------------- /Slides/Lecture4.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonnynomnom/CMP-167-Programming-Methods-I/90c8cc5a602b7e9d2b1d181c5a82bcb00c430591/Slides/Lecture4.pdf -------------------------------------------------------------------------------- /Slides/Lecture5.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonnynomnom/CMP-167-Programming-Methods-I/90c8cc5a602b7e9d2b1d181c5a82bcb00c430591/Slides/Lecture5.pdf -------------------------------------------------------------------------------- /Speed1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonnynomnom/CMP-167-Programming-Methods-I/90c8cc5a602b7e9d2b1d181c5a82bcb00c430591/Speed1.pdf -------------------------------------------------------------------------------- /Syllabus.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonnynomnom/CMP-167-Programming-Methods-I/90c8cc5a602b7e9d2b1d181c5a82bcb00c430591/Syllabus.pdf -------------------------------------------------------------------------------- /Textbook/Chapter 1. The Way of the Program.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonnynomnom/CMP-167-Programming-Methods-I/90c8cc5a602b7e9d2b1d181c5a82bcb00c430591/Textbook/Chapter 1. The Way of the Program.pdf -------------------------------------------------------------------------------- /Textbook/Chapter 2. Variables and Operators.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonnynomnom/CMP-167-Programming-Methods-I/90c8cc5a602b7e9d2b1d181c5a82bcb00c430591/Textbook/Chapter 2. Variables and Operators.pdf -------------------------------------------------------------------------------- /Textbook/Chapter 3. Input and Output.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonnynomnom/CMP-167-Programming-Methods-I/90c8cc5a602b7e9d2b1d181c5a82bcb00c430591/Textbook/Chapter 3. Input and Output.pdf -------------------------------------------------------------------------------- /Textbook/Chapter 4. Void Methods.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonnynomnom/CMP-167-Programming-Methods-I/90c8cc5a602b7e9d2b1d181c5a82bcb00c430591/Textbook/Chapter 4. Void Methods.pdf -------------------------------------------------------------------------------- /Textbook/Chapter 5. Conditionals and Logic.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonnynomnom/CMP-167-Programming-Methods-I/90c8cc5a602b7e9d2b1d181c5a82bcb00c430591/Textbook/Chapter 5. Conditionals and Logic.pdf -------------------------------------------------------------------------------- /Textbook/Chapter 7. Loops.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonnynomnom/CMP-167-Programming-Methods-I/90c8cc5a602b7e9d2b1d181c5a82bcb00c430591/Textbook/Chapter 7. Loops.pdf -------------------------------------------------------------------------------- /Textbook/Chapter 8. Arrays.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonnynomnom/CMP-167-Programming-Methods-I/90c8cc5a602b7e9d2b1d181c5a82bcb00c430591/Textbook/Chapter 8. Arrays.pdf -------------------------------------------------------------------------------- /granit.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonnynomnom/CMP-167-Programming-Methods-I/90c8cc5a602b7e9d2b1d181c5a82bcb00c430591/granit.jpg -------------------------------------------------------------------------------- /logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonnynomnom/CMP-167-Programming-Methods-I/90c8cc5a602b7e9d2b1d181c5a82bcb00c430591/logo.png -------------------------------------------------------------------------------- /ratemyprofessors.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonnynomnom/CMP-167-Programming-Methods-I/90c8cc5a602b7e9d2b1d181c5a82bcb00c430591/ratemyprofessors.png -------------------------------------------------------------------------------- /yelp.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonnynomnom/CMP-167-Programming-Methods-I/90c8cc5a602b7e9d2b1d181c5a82bcb00c430591/yelp.jpg --------------------------------------------------------------------------------