diff --git a/chapter_2.md b/Chapter_2.md similarity index 72% rename from chapter_2.md rename to Chapter_2.md index 0a17cc9..b48d3dc 100644 --- a/chapter_2.md +++ b/Chapter_2.md @@ -25,42 +25,52 @@ Problem: Start this with pseudocode #### Variables -These are named places to hold information in your program. The informaiton can be of different types: a char, a sequenc of characters (String), an integer, a number with a decimal (Float), a list, a dictionary, a grid of one of these types. +These are named places to hold information in your program. The informaiton can be of different types: a char, a sequence of characters (String), an integer, a number with a decimal (Float), a list, a dictionary(include array and etc) , a grid of one of these types. Each variable is like a pad of sticky notes. You can write on the front sheet, and when you want, you can rip that sheet off, and write something (possibly different) on the newly exposed sheet. The variable name holds the information on the currently showing sticky note. #### Operators -You are familar with multiple binary operators (meaingin they work on two items at once). Multiplication * , Division / , Addition + , Subtraction - . +You are familar with multiple binary operators (meaning in they work on two items at once). Multiplication * , Division / , Addition + , Subtraction - . Modulo(%) is used instead of division (/) when dealing with int because if there is a decimal it is trunkated(cutout) -Does order mater with the operands of an operator? (the order of the items that are passed to the operator?) +Does order matter with the operands of an operator? (the order of the items that are passed to the operator?) If we are only able to use integers for the above operations, what piece of information are we loosing when we store the answer back to an integer? The operator to get this info with one step is the % operator. We have a special operator, it is the assignment operator. This is the operator that removes the top sheet of the stickynote pad and writes a value on the next sheet. In Java we will use a single equals sign to indicate this. In your book they use a left pointing arrow in pseudocode to represent this. You can probably guess that a variable must be on the left side (the sticky note pad we are going to place a value on for later use), and a value of the appropriate type on the right hand side. -if all letters in the next lines are integers, is the folowing valid, why: + +if all letters in the next lines are integers, is the following valid, why: * a = b + c - * g = h / i - * r + s = t * u + when evaluating the statement above the addition is done first (all of the rules of operand is done) and assignment done last + as it process it does the following a=(b+c) + **g = h / i + Same as first * + + *** r + s = t * u + INVAILD- does not work + There are other operators that we will talk about as the class progresses. ##### testing operators -There are operators that return true or false instead of a numeric value. Many of these you are already familar with, and most are binary (take two operands): - * < less than - * > greater than - * <= less than or equal to - * >= greater than or equal to - * == equal to - * != not equal to + +There are operators that return true or false instead of a numeric value. Many of these you are already familar with, and most are BINARY (take two operands): + (1) < less than + (2) > greater than + (3) <= less than or equal to + (4) >= greater than or equal to + (5) == equal to + (6) != not equal to You can also combine logic tests together with the operators: - * && 'and' returns true if the items on either side are both true - * || 'or' returns true if at least one of the items on it's sides is true. - -Finally our first unary operator (meaning it only takes one operand) - * ! 'not' returns false if the operand following it is ture, and returns true if that operand is false + (7) && 'and' returns true if the items on either side are both true + (8) || 'or' returns true if at least one of the items on it's sides is true. +Finally our first UNARY operator (meaning it only takes one operand) + * ! 'not' returns false if the operand following it is true, and returns true if that operand is false + ** Can be used to negate statements + ie: !(a==5) reads as return true for a not equal to 5 + #### Tracing a program This is a skill that helps you track down what is happening during a program to find why it is not giving you the result you expected it to. @@ -71,7 +81,9 @@ We will start by doing this on paper, and as we get towards coding, we will lear #### Input and Output A computer is a great tool, and it can do a lot. However if we can't communicate with it, it does us little good. -This is just trying to make you aware that we need tha ability to provide informaiton to our programs, and for our programs to provide inforamiotn back to us if we want the programs to truely be useful. + +This is just trying to make you aware that we need tha ability to provide informaiton to our programs, and for our programs to provide information back to us if we want the programs to truely be useful. + For the sake of flowcharts, you can use the words input and output (print) for these steps. The book also uses these terms in it's fomalized pseudocode examples. @@ -80,10 +92,12 @@ We can string these above steps together, but we need ways to only do the steps ##### If structure: * if do this poriton of code only if the test is true - * if - else same as the if, but has a second porion of code that is followed only if the test is not true. + * if - else same as the if, but has a second portion of code that is followed only if the test is not true. * if - else if Same as if-else, however only runs the second poriton if the first test if false and a second is true. -How to determin which to use? Partially practice, and being *lazy*. +How to determine which to use? Partially practice, and being *lazy*. + + Write out an example of a program that gives an indication of a kid of what they should wear based upon the tempature. @@ -104,3 +118,8 @@ The book describes this and two other methods of using a loops test to stop the ##### Combining these control structures: + + + + + diff --git a/Chapter_3 Updated.md b/Chapter_3 Updated.md new file mode 100644 index 0000000..c4aebd0 --- /dev/null +++ b/Chapter_3 Updated.md @@ -0,0 +1,191 @@ +## Chapter 3 + +In this chapter we will start coding and talking about how the various portions of the Java language work. + +### How do we convert our flow charts to code? + +We have been using three things in our flowcharts: + +#### Statements: +~~~ ++---------------------------+ +| Decrease the counter by 1 | ++---------------------------+ +~~~ +~~~ ++---------------+ +| Print "Hello" | ++---------------+ +~~~ +If they are simple, these will generally translate into a sngle line of code: +~~~ +counter = counter -1; + +system.out.print("Hello"); +~~~ +If they are complex, then we need to break them down further. As an example think of the statements in my algorithm where I asked does everyone know about the meeting. + +#### Conditionals: +~~~ + | + | + v + / \ + / \ Yes + if our counter \-----------+ + equals 5 / | + \ / v + \ / +---------------+ + | | Statement 1 | + No | +---------------+ + v | ++-----------------+ v +| Statement 3 | +---------------+ ++-----------------+ | Statement 2 | + | +---------------+ + | | + +-------------------+ + | + v +~~~ + +This translates into the code: +~~~ +if( counter == 5 ) +{ + Statement 1 + Statement 2 +} +else +{ + Statement 3 +} +~~~ + +#### loops + +Any time we have an edge going back to a previous step, we have a loop. Thi is an indication that we want to do some steps multiple times. + +When we have a loop either it has a conditional in it somewhere that has oneoption tht leaves the loop, or we have a never ending, infinate loop. We don't want infinate loops, so I'm going to assume that you have such a conditional in the sequence of steps that is repeated, similar to below: +~~~ + | + v + +---------------+ + | Statement 5 | + +---------------+ + | ++-------->| +| | +| v +| +---------------+ +| | Statement 6 | +| +---------------+ +| | +| v +| / \ +| / \ Yes +---------------+ +| if temp is less \ --------->| Statement 9 | +| than 50 / +---------------+ +| \ / | +| \ / | +| | No | +| v | +| +---------------+ | +| | Statement 7 | | +| +---------------+ | +| | | +| v | +| +---------------+ | ++-| Statement 8 | | + +---------------+ | + v + ~~~ + +For this we will wait to start the loop until we get to the conditional, then we will create a loop with the exit condition: + +~~~ +Statement 5 +Statement 6 +while( temp >= 50 ) +{ + Statement 7 + Statement 8 + Statement 6 +} +Statement 9 +~~~ + +Note that with this condition we had to invert it, as the written test in the flowchart tested to exit the loop, not stay in it. + +#### Tests +How can we test things in conditionals and loops? +~~~ +When we test something we want the result to be true or false. We know of some of these and use them regularly: +* < less than +* > greater than +* == is equal to +* <= less than or equal to +* >= greater than or equal to +~~~ +What if we need something to not be one of these things? For that we have a not opperator: +* ! + +it can be used with the is equal to opperator to modifyit: +* != is not equal to + +or it can be used with any test: +* !( 5 > 8 ) + +note the parenthesis here to indicate what we want the oppisite truth value of (parenthesis still evaluate before the not opperator.) + +How could you write the above "temp is less than 50" test other than changing the less than opperator? + + +So you may be asking "What do I do if things get more complicated?" For example what if you needed to test if a value was less than 10 or greater than 90? + +There are multiple ways to do this, but to introduce you to one more tool for tests, I'm going to choose the method that is closest to what was written: +* (value < 10) || (value > 90) + +There are two of these opperators: +* || logical OR. If the item on either side is true, then return true, otherwise return false. +* && logical AND. Only when the item on both sides is true, return true, otherwise return false. + + +This allows us to build up some wild sentances and translate them into logic: +If it is not the case that either the sky is blue or the water is red. + +becomes: +if( !( (sky == blue) || (water == red) ) ) + +### Comments in Java +~~~ +Use // to indicate that everything after is a comment *works for one row* +Use /*_____*/ to indicate that everything in between is to be seen as a comment + Use comments for assistance too many can be very messy and unneccessary +~~~ + +### Initial Set Up +~~~ +- public class (NAME of File) + { + public static void main(String[]args) (*** These two things are needed to have java run/ This MAIN is a function**) + { + } + } +~~~ +### Switch Statements +~~~ +int i +switch(i%5) +{ +case 0: + -insert commands if condition met for this case - +case 1 +case 2 +case 3 +case 4 +default: +print 'i is a multiple of 5" +} + +~~~ diff --git a/CodeExamples/Calculator/Calculator.java b/CodeExamples/Calculator/Calculator.java new file mode 100644 index 0000000..8589da6 --- /dev/null +++ b/CodeExamples/Calculator/Calculator.java @@ -0,0 +1,62 @@ +import java.util.Scanner; + +public class Calculator { + + public static void main(String[] args) { + + Stack numbers = new Stack(); + + // "5 3 + 7 *" + Scanner sysIn = new Scanner("5 3 % "); + + while( sysIn.hasNextLine() ) { + String input = sysIn.nextLine(); + + Scanner process = new Scanner(input); + + while( process.hasNext() ) { + String symbol = process.next(); + + switch(symbol) { + case "+": + case "-": + case "*": + case "/": + case "%": + calculate(symbol, numbers); + break; + default: + numbers.push( Float.valueOf(symbol) ); + } + } + } + + System.out.println(numbers.stackSize()); + + System.out.println(numbers.pop()); + + + } + + public static void calculate(String op, Stack stack) { + Float y = stack.pop(); + Float x = stack.pop(); + switch( op ) { + case "+": + stack.push(x + y); + break; + case "-": + stack.push(x - y); + break; + case "*": + stack.push(x * y); + break; + case "/": + stack.push(x / y); + break; + case "%": + stack.push(x % y); + } + + } +} diff --git a/CodeExamples/Calculator/Stack.java b/CodeExamples/Calculator/Stack.java new file mode 100644 index 0000000..f85a02e --- /dev/null +++ b/CodeExamples/Calculator/Stack.java @@ -0,0 +1,39 @@ +public class Stack { + + private Float[] stack = new Float[5]; + private int size = 5; + private int numberOfItems = 0; + + + private void increaseStackSize() { + Float[] newStack = new Float[size*2]; + size = size * 2; + for( int i=0; i= 0 ) + { + if( number < 2) + System.out.print("1"); + else { + long[] calculate = new long[number + 1]; + calculate[0]=1; + calculate[1]=1; + for( int i = 2; i< number+1; i++) + { + calculate[i] = calculate[i-1] + calculate[i-2]; + } + System.out.println(calculate[number]); + } + } + else + System.out.println("You must enter an integer that is not negative."); + } +} diff --git a/CodeExamples/Functions/fiboRecursive.java b/CodeExamples/Functions/fiboRecursive.java new file mode 100644 index 0000000..902a1d6 --- /dev/null +++ b/CodeExamples/Functions/fiboRecursive.java @@ -0,0 +1,22 @@ +import java.util.Scanner; + +public class fiboRecursive { + + private static long fibo(int number) + { + System.out.print(number + " "); + if( number < 2) + return 1; + return fibo(number-1) + fibo(number-2); + } + + public static void main(String[] args) + { + Scanner sysIn = new Scanner(System.in); + int number = sysIn.nextInt(); + long result = fibo(number); + + System.out.println( ); + System.out.println( result ); + } +} diff --git a/CodeExamples/Functions/tictactoe.java b/CodeExamples/Functions/tictactoe.java new file mode 100644 index 0000000..081a8d4 --- /dev/null +++ b/CodeExamples/Functions/tictactoe.java @@ -0,0 +1,88 @@ +import java.util.Scanner; + +public class tictactoe { + +    private static void setUpBoard(int[][] board2) + {       + for( int i=0; i<3; i++)   + for(int j=0; j<3; j++)       + board2[i][j] = 0;  + } + + private static void firstPlayerPlays(int location, int[][] board)    + { +     makePlay(location, board, 1);    + } + + public static int changePlayer(int player)    + { +    if( player == 1)    + return 2;   + else     + return 1; + } + +    private static void makePlay(int location, int[][] board, int player) + { + board[(location-1) / 3][(location-1) % 3] = player; + } + +    private static boolean someOneHasWon(int[][] board, int currentPlayer) + {        + for(int i = 0; i<3; i++)      + {         + if (    board[i][0] == currentPlayer &&                + board[i][1] == currentPlayer &&            + board[i][2] == currentPlayer)         + {        + return true;  + } +         + if (    board[0][i] == currentPlayer &&                    + board[1][i] == currentPlayer &&                    + board[2][i] == currentPlayer)          + {        + return true;        + }    + } +        + if (    board[0][0] == currentPlayer &&                + board[1][1] == currentPlayer &&                + board[2][2] == currentPlayer)      + {        + return true;    + } + +        if (    board[0][2] == currentPlayer &&                + board[1][1] == currentPlayer &&                + board[2][0] == currentPlayer)        + {            + return true;      + } + + return false;  + } + + public static void main(String[] args)    + { + Scanner sysIn = new Scanner(System.in);   + + int[][] board = new int[3][3];     + int playLocation, currentPlayer = 1; +        + setUpBoard(board); +        + playLocation = sysIn.nextInt();    + firstPlayerPlays(playLocation, board); +        + while( !someOneHasWon(board, currentPlayer) )   + {        + currentPlayer = changePlayer(currentPlayer); +            playLocation = sysIn.nextInt();        + + makePlay(playLocation, board, currentPlayer);  + } + +        displayResults();    + } +} diff --git a/CodeExamples/Functions/tictactoeComplete.java b/CodeExamples/Functions/tictactoeComplete.java new file mode 100644 index 0000000..b1af4f8 --- /dev/null +++ b/CodeExamples/Functions/tictactoeComplete.java @@ -0,0 +1,114 @@ +import java.util.Scanner; +public class tictactoe +{ + + private static void setUpBoard(int[][] board2) + { + for( int i=0; i<3; i++) + for(int j=0; j<3; j++) + board2[i][j] = 0; + } + + private static void firstPlayerPlays(int location, int[][] board) + { + makePlay(location, board, 1); + } + + public static int changePlayer(int player) + { + if( player == 1) + return 2; + else + return 1; + } + + private static void makePlay(int location, int[][] board, int player) + { + board[(location-1) / 3][(location-1) % 3] = player; + } + + private static boolean someOneHasWon(int[][] board, int currentPlayer) + { + for(int i = 0; i<3; i++) + { + if ( board[i][0] == currentPlayer && + board[i][1] == currentPlayer && + board[i][2] == currentPlayer) + { + return true; + } + if ( board[0][i] == currentPlayer && + board[1][i] == currentPlayer && + board[2][i] == currentPlayer) + { + return true; + } + } + if ( board[0][0] == currentPlayer && + board[1][1] == currentPlayer && + board[2][2] == currentPlayer) + { + return true; + } + + if ( board[0][2] == currentPlayer && + board[1][1] == currentPlayer && + board[2][0] == currentPlayer) + { + return true; + } + return false; + } + + private static boolean checkValidPlay(int placeToPlay, int[][] board) + { + if( board[(placeToPlay-1) / 3][(placeToPlay-1) %3] == 0) + return true; + return false; + } + + public static void displayResults(int[][] board) + { + if( someOneHasWon(board, 1) ) + System.out.println("Player 1 has won!"); + else if( someOneHasWon( board, 2)) + System.out.println("Player 2 has won!"); + else + System.out.println("The game is a draw."); + } + + public static void main(String[] args) + { + Scanner sysIn = new Scanner(System.in); + int[][] board = new int[3][3]; + int playLocation, currentPlayer = 1; + + setUpBoard(board); + playLocation = sysIn.nextInt(); + + firstPlayerPlays(playLocation, board); + int turns = 1; + boolean invalidPlay = false; + + while( !someOneHasWon(board, currentPlayer) && turns<=9 && !invalidPlay) + { + currentPlayer = changePlayer(currentPlayer); + for(int i=0; i<3; i++) + { + for (int j = 0; j < 3; j++) + System.out.print(board[i][j]); + System.out.println(); + } + playLocation = sysIn.nextInt(); + if( checkValidPlay(playLocation, board) ) + makePlay(playLocation, board, currentPlayer); + else + { + System.out.println("Not a valid play!"); + invalidPlay = true; + } + } + if( ! invalidPlay ) + displayResults(board); + } +} diff --git a/CodeExamples/Object Oriented/Array/ArrayDriver.java b/CodeExamples/Object Oriented/Array/ArrayDriver.java new file mode 100644 index 0000000..6b01bb8 --- /dev/null +++ b/CodeExamples/Object Oriented/Array/ArrayDriver.java @@ -0,0 +1,22 @@ +import java.util.Scanner; + +public class ArrayDriver { + + public static void main(String[] args) { + + IntArray list = new IntArray(); + + Scanner SysIn = new Scanner(System.in); + + int value = SysIn.nextInt(); + + while( value != 0 ) { + list.add(value); + value = SysIn.nextInt(); + } + + for(int i = 0; i < list.size; i = i + 1) { + System.out.print(list.array[i] + " "); + } + } +} diff --git a/CodeExamples/Object Oriented/Array/IntArray.java b/CodeExamples/Object Oriented/Array/IntArray.java new file mode 100644 index 0000000..15197c0 --- /dev/null +++ b/CodeExamples/Object Oriented/Array/IntArray.java @@ -0,0 +1,23 @@ +public class IntArray { + + public int[] array; + public int size; + + public IntArray() { + size = 0; + array = new int[size]; + } + + public void add(int value) { + size = size + 1; + int[] tempArray; + tempArray = new int[size]; + + for(int i=0; i< size - 1; i++) { + tempArray[i] = array[i]; + } + + array = tempArray; + array[size - 1] = value; + } +} diff --git a/CodeExamples/Object Oriented/Point/Point.java b/CodeExamples/Object Oriented/Point/Point.java new file mode 100644 index 0000000..815ca07 --- /dev/null +++ b/CodeExamples/Object Oriented/Point/Point.java @@ -0,0 +1,18 @@ +public class Point { + + public int x; + public int y; + + public double distanceTo(Point remotePoint) { + double subResult = Math.pow( x-remotePoint.x , 2) + Math.pow( y-remotePoint.y , 2); + + return Math.sqrt( subResult); + } + + public static double distanceBetween( Point p1, Point p2) { + double subResult = Math.pow( p1.x-p2.x , 2) + Math.pow( p1.y-p2.y , 2); + + return Math.sqrt( subResult); + } + +} diff --git a/CodeExamples/Object Oriented/Point/triangle.java b/CodeExamples/Object Oriented/Point/triangle.java new file mode 100644 index 0000000..2f05b02 --- /dev/null +++ b/CodeExamples/Object Oriented/Point/triangle.java @@ -0,0 +1,53 @@ +import java.util.Scanner; + +public class triangle { + + public static void main(String []args) { + Scanner SysIn = new Scanner(System.in); + + Point p1, p2, p3; + + Integer x, y; + x = SysIn.nextInt(); + y = SysIn.nextInt(); + + p1 = new Point(); + + p1.x = x; + p1.y = y; + + x = SysIn.nextInt(); + y = SysIn.nextInt(); + + p2 = new Point(); + + p2.x = x; + p2.y = y; + + x = SysIn.nextInt(); + y = SysIn.nextInt(); + + p3 = new Point(); + + p3.x = x; + p3.y = y; + + + + System.out.println("The points are: "); + + System.out.println("("+ p1.x + "," + p1.y + ")"); + System.out.println("("+ p2.x + "," + p2.y + ")"); + System.out.println("("+ p3.x + "," + p3.y + ")"); + + System.out.println("The distance between the points is: "); + System.out.println( p1.distanceTo(p2) ); + System.out.println( p1.distanceTo(p3) ); + System.out.println( p2.distanceTo(p3) ); + + System.out.println("The distance between the points is: "); + System.out.println( Point.distanceBetween(p1,p2) ); + System.out.println( Point.distanceBetween(p1,p3) ); + System.out.println( Point.distanceBetween(p2,p3) ); + } +} diff --git a/CodeExamples/fizzBuzzMethods.java b/CodeExamples/fizzBuzzMethods.java new file mode 100644 index 0000000..e1a8bc9 --- /dev/null +++ b/CodeExamples/fizzBuzzMethods.java @@ -0,0 +1,29 @@ +import java.util.Scanner; + +public class fizzBuzzMethods { + + public static void main(String[] args) + { + Scanner sysIn = new Scanner(System.in); + int value = sysIn.nextInt(); + + for( ; value > 1; value = value - 1) + { + fizz(value); + buzz(value); + System.out.println(); + } + } + + private static void fizz(int number) + { + if( number % 2 == 0 ) + System.out.print("fizz"); + } + + private static void buzz(int number) + { + if( number % 3 == 0 ) + System.out.print("buzz"); + } +} diff --git a/CodeExamples/math.java b/CodeExamples/math.java new file mode 100644 index 0000000..b9fe2d9 --- /dev/null +++ b/CodeExamples/math.java @@ -0,0 +1,32 @@ +public class math { + + public static void main(String[] args) + { + System.out.println( ((5+4)-12) + " : " + subtract(add(5,4),12) ); + + } + + private static int add(int x, int y) + { + int result = 0; + for( int i=0; i < x; i = i + 1) + result = result + 1; + + for( int i=1; i <= y; i= i + 1) + result = result + 1; + + return result; + } + + private static int subtract(int x, int y) + { + int result = add(x,0); + + for( int i=0; i < y; i = i + 1) + result = result - 1; + + return result; + } + + +} diff --git a/CodeExamples/test1.java b/CodeExamples/test1.java new file mode 100644 index 0000000..a93610c --- /dev/null +++ b/CodeExamples/test1.java @@ -0,0 +1,13 @@ +public class test1 { + + public static void main(String[] args) { + + for (int i = 1; i <= 10; i = i + 1) { + for (int k = 1; k <= 10; k = k + 1) { + System.out.print(i * k + " "); + } + System.out.println(); + } + + } +} diff --git a/Covered Sections.md b/Covered Sections.md new file mode 100644 index 0000000..9771084 --- /dev/null +++ b/Covered Sections.md @@ -0,0 +1,34 @@ +These are the sections that we have currently covered from the book: + +### Chapter 2 +All sections except: + * 2.9 Loop Termination Techniques (Read on your own) + * 2.11 Tracing (Delayed) + * 2.12 Other Pseudocode Formats (Read on your own) + + ### Chapter 3 + All section except: + * 3.14 Constants (Delayed) + * 3.19 Type Casting (Delayed) + * 3.24 File input and output (Delayed) + * 3.25 GUI + + ### Chapter 4 + All sections except: + * 4.14 Input Validation (Read on your own) + * 4.15 Boolean Logic (Read on your own) + + ### Chapter 5 + All sections except: + * 5.7 printf (Partially covered, read on your own) + * 5.8 using random numbers (Read on your own) + * 5.9 GUI + * 5.10 GUI + + Note these reference chapters: + 5.3 Math Class (Shows some of the functions) + 5.5 Character Class (Shows some of the functions) + 5.6 String Methods (Shows some of the functions) + + ### Chapter 9 + We ave worked through 9.1, 9.2, and 9.3 (except for default values) diff --git a/First Excerise/.idea/misc.xml b/First Excerise/.idea/misc.xml new file mode 100644 index 0000000..4c1c37a --- /dev/null +++ b/First Excerise/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/First Excerise/.idea/modules.xml b/First Excerise/.idea/modules.xml new file mode 100644 index 0000000..c4fd645 --- /dev/null +++ b/First Excerise/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/First Excerise/.idea/workspace.xml b/First Excerise/.idea/workspace.xml new file mode 100644 index 0000000..0f84560 --- /dev/null +++ b/First Excerise/.idea/workspace.xml @@ -0,0 +1,344 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1517885553742 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No facets are configured + + + + + + + + + + + + + + + 1.8 + + + + + + + + hw1 + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/hw1-Jeff/hw1.iml b/hw1-Jeff/hw1.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/hw1-Jeff/hw1.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/hw1-Jeff/out/production/hw1/ThreeNplus1.class b/hw1-Jeff/out/production/hw1/ThreeNplus1.class new file mode 100644 index 0000000..0bfc3ab Binary files /dev/null and b/hw1-Jeff/out/production/hw1/ThreeNplus1.class differ diff --git a/hw1-Jeff/src/ThreeNplus1.java b/hw1-Jeff/src/ThreeNplus1.java new file mode 100644 index 0000000..f557d49 --- /dev/null +++ b/hw1-Jeff/src/ThreeNplus1.java @@ -0,0 +1,25 @@ +public class ThreeNplus1 +{ + + public static void main(String[] args) + { + int count = 0; + for (int i=100; i>1; i--, count = 0) + { + for(int n=i; n>1; count++) + { + if( n%2==0 ) + { + n=n/2; + } + else + { + n=n*3+1; + } + System.out.print(n + " "); + } + System.out.println(); + System.out.println("It took " + count + " steps to get to 1 for " + i + "."); + } + } +} diff --git a/jhinze/Array b/jhinze/Array new file mode 100644 index 0000000..177ba7e --- /dev/null +++ b/jhinze/Array @@ -0,0 +1,62 @@ +IntArray +public class IntArray { + + public int[] array; + public int size; + + public IntArray() { + size = 0; + array = new int[size]; + } + + public void add(int value) { + size = size + 1; + int[] tempArray; + tempArray = new int[size]; + + for(int i=0; i< size - 1; i++) { + tempArray[i] = array[i]; + } + + array = tempArray; + array[size - 1] = value; + } + public int sumOf() + { + int sum = 0; + + for(int i=0; i< size; i++) + { + sum = sum + array[i]; + } + return sum; + } +} + + + + +ArrayDriver +import java.util.Scanner; + +public class ArrayDriver { + + public static void main(String[] args) { + + IntArray list = new IntArray(); + + Scanner SysIn = new Scanner(System.in); + + int value = SysIn.nextInt(); + + while( value != 0 ) { + list.add(value); + value = SysIn.nextInt(); + } + + for(int i = 0; i < list.size; i = i + 1) { + System.out.print(list.array[i] + " "); + } + System.out.print(list.sumOf()); + } +} diff --git a/jhinze/Point b/jhinze/Point new file mode 100644 index 0000000..1bcb1b7 --- /dev/null +++ b/jhinze/Point @@ -0,0 +1,88 @@ +Point + +public class Point { + + public int x; + public int y; + + public double distanceTo(Point remotePoint) { + double subResult = Math.pow( x-remotePoint.x , 2) + Math.pow( y-remotePoint.y , 2); + + return Math.sqrt( subResult); + } + + public static double distanceBetween( Point p1, Point p2) { + double subResult = Math.pow( p1.x-p2.x , 2) + Math.pow( p1.y-p2.y , 2); + + return Math.sqrt( subResult); + } + + public static double slopeBetween( Point p1, Point p2) + { + double Result = (p2.y-p1.y)*(1.0) / (p2.x-p1.x)*(1.0); + return Result; + + } +} + + +triangle + +import java.util.Scanner; + +public class triangle { + + public static void main(String []args) { + Scanner SysIn = new Scanner(System.in); + + Point p1, p2, p3; + + Integer x, y; + x = SysIn.nextInt(); + y = SysIn.nextInt(); + + p1 = new Point(); + + p1.x = x; + p1.y = y; + + x = SysIn.nextInt(); + y = SysIn.nextInt(); + + p2 = new Point(); + + p2.x = x; + p2.y = y; + + x = SysIn.nextInt(); + y = SysIn.nextInt(); + + p3 = new Point(); + + p3.x = x; + p3.y = y; + + + + System.out.println("The points are: "); + + System.out.println("("+ p1.x + "," + p1.y + ")"); + System.out.println("("+ p2.x + "," + p2.y + ")"); + System.out.println("("+ p3.x + "," + p3.y + ")"); + + System.out.println("The distance between the points is: "); + System.out.println( p1.distanceTo(p2) ); + System.out.println( p1.distanceTo(p3) ); + System.out.println( p2.distanceTo(p3) ); + + System.out.println("The distance between the points is: "); + System.out.println( Point.distanceBetween(p1,p2) ); + System.out.println( Point.distanceBetween(p1,p3) ); + System.out.println( Point.distanceBetween(p2,p3) ); + + System.out.println( "The slopes between the points are: "); + System.out.println( Point.slopeBetween(p1,p2) ); + System.out.println( Point.slopeBetween(p1,p3) ); + System.out.println( Point.slopeBetween(p2,p3) ); + } +} diff --git a/syllabus.pdf b/syllabus.pdf new file mode 100644 index 0000000..27337c1 Binary files /dev/null and b/syllabus.pdf differ