Information Technology (IT)

Grading

Java Text Book: Introduction to Programming with Java

Java Tutorial: https://docs.oracle.com/javase/tutorial/tutorialLearningPaths.html


*** Email your final Project PDF file to [email protected] , [email protected] , or [email protected] , depending on if you are in class 1, class 2, or class 3.

It is due by the end of the day on January 10th.

Each group should send just one email with just one PDF file attached. ***


Lecture Notes

For the midterm and final exams, you only need to know what was taught in the lectures, which is summarized in the notes. The references address the central topics of the lecture, but include additional material.

Week 14

Week 14 lecture notes

References:

What is an Object?
What is a Class?

Primitive vs. Reference Type Variables in Java :

Diagrams
  • Primitive vs. Reference Step 1
  • Primitive vs. Reference Step 2
  • Source Files
  • Primitive.java
  • Reference.java
  • Week 12

    Week 12 lecture notes

    References:

    Arrays

    Week 10

    Week 10 lecture notes

    Week 7

    Week 7 lecture notes

    References:

    Variables
    Primitive Data Types

    Weeks 3 & 4

    Week 3 lecture notes
    Week 4 lecture notes

    References:

    Binary Tutorial
    Computer Number Systems
    Boolean Algebra

    Assignments:

    Week 2.8

    Read Java Text Book pp. 667-670

    Week 2.1

    Read Java Text Book pp. 644-652

    Week 14

    Read the Matrices Tutorial so that, for a scalar s and two matrices A and B of appropriate dimensions, you can compute A + B, sA, A - B, AT, AB, |A|, and A-1. For ways of calculating A-1, see 2x2 Inverse. There are links at the bottom of that page to pages that explain how to find the inverse of a matrix that is larger than 2x2. For ways of calculating |A|, see Determinant.

    Week 10

    Read Java Text Book: pp. 25-40

    Week 2

    Read Java Text Book: pp. 1-22


    NOTE: Java Text Book page 1 is page 35 of the PDF. In the assignments and labs, the page numbers are the actual book page numbers (not the PDF page numbers). To calculate the PDF page number, just add 34 to the actual book page number!


    Labs:

    Week 2.11

    Beginning with LayoutExample3.java , implement a JButton to transfer the matrix data from the JTextArea (cArea) to the A matrix' JTextFields.

    Make sure to use the current Matrix.java . This has a Matrix(String data, String delimeter) constructor that will be very useful.

    Week 2.9

    1. Add an "AB" button to the south panel. Use the "A+B" button as an example.

    2. Resize the Matrix C when necessary for AB. See LayoutExample2 above.

    LayoutExample.java

    Matrix.java

    Week 2.7

    1. Add an "AB" button to the south panel. Use the "A+B" button as an example.

    LayoutExample.java

    Matrix.java

    Week 2.5

    I. Modify the SimpleWindow program to open an input dialog box prompting the user to enter their name. Use System.out.println() to write the user input String [obtained from JOptionPane.showInputDialog()] to the console.

    II. Update the label text using the user input String. To do this, make the declaration of the JLabel a static field of the SimpleWindow class. Then you can call setText() on the label from inside main().

    SimpleWindow.java

    SimpleWindow2.java

    SimpleWindow3.java

    Week 2.3

    Implement a simple AWT/Swing application that presents a window (JFrame) with an input text box (JTextField), an output text box, and a "Factorial" button (JButton). The user should be able to type a small integer into the input text box, and then click the button to see the factorial of the input integer displayed in the output text box. You can begin with the code on pages 665-666 in section 16.12.

    Week 2.1

    Implement a simple AWT/Swing application that displays a message in a JLabel component. The JLabel should be added to a JFrame. You can begin with the code on pg. 648 of Java Text Book. Try making some changes, and begin considering how to implement your project using AWT/Swing.

    SimpleWindow.java

    SimpleWindow2.java

    SimpleWindow3.java


    Week 16

    MatrixTest.java

    Matrix.java [Complete the Matrix.multiply(int a) method: Given a Matrix A and an int a, A.multiply(a) should return a new Matrix that is the same as Matrix A but with each element multiplied by a. Add a test of the multiply method in MatrixTest.java, similar to the test of the add method. Then finish the remaining operations: A - B, AT, AB, |A|, and A-1. For ways of calculating A-1, see 2x2 Inverse. There are links at the bottom of that page to pages that explain how to find the inverse of a matrix that is larger than 2x2. For ways of calculating |A|, see Determinant.]

    Week 15

    PolygonTestG.java

    Polygon.java (Fill in the blanks: BLANK_0, BLANK_1, BLANK_2)

    Point.java

    Week 13

    Primes.java (Fill in the blanks: BLANK_0, BLANK_1, ..., BLANK_4.)

    Week 11

       Write a program that chooses a number between 1 and 1,000,000 and then asks you to guess the number. 
    If your guess is correct, the program should print "you win" as well as the number of guesses you took 
    to find the number, and then terminate. If your guess is incorrect, the program should print "higher" 
    or "lower" accordingly and then ask you for another guess. See fig. 8 in the Week 10 lecture notes for Scanner code and loop 
    structures that you might find helpful. 
    
    Math.random() returns a double in the range [0,1).  To choose an integer between 1 and 1000000, you can use 
     
    int secret = (int)(Math.random() * 1000000) + 1;
     
    For extra credit : determine an upper bound on the number of guesses needed to find the number.
    Compare the number of guesses the user took to find the number with this upper bound to determine a
    score.
    
    Math.log(x) returns the base-10 log of x.  You can compute the base-2 log of a number x using the fact that 
    
    log_2(x) = log_10(x)/log_10(2)
    

    Week 8

    public class Calculations {
    	public static void main(String[] args) {
    		float PI = 3.1415f;
    		
    		float r = 1;
    		float a, c;
    		
    		a = ; // BLANK_0 : PIr^2
    		c = ; // BLANK_1 : 2PIr
    		
    		System.out.println("a = " + a);
    		System.out.println("c = " + c);
    		
    		// Convert the temperature from Celcius (C)
    		// to Fahrenheit (F).
    		
    		float t_c = 22;
    		float t_f = ; // BLANK_2 : (9/5)t_c + 32
    		
    		System.out.println(t_c + "C" + " = " + t_f + "F");
    		
    	}
    }

    Week 4

    public class XOR {
        public static void main(String[] args) {
            int a = 5;
            int b = 7;
            
            System.out.println(a + " " + b);
    
            a = a ^ b; // Step 1
                       // Step 2
                       // Step 3
                       
            // Complete the final two steps of this algorithm using only the XOR (^) and the assignment (=) operators, without using a temporary variable.  
            // The next two steps are similar to the final two steps of the previous variation of this algorithm, which uses + and -.  (See the Week 4 lecture notes.) 
            // HINT: How can XOR be used to get the same result as the subtraction step in the previous variation of this algorithm?  
            //       What is the value of (a ^ b) ^ b ?
    
            System.out.println(a + " " + b);
        }
    }
            

    Week 2

    1. Use the IntelliJ IDE installed on your lab computer to create, build, and run the example Java program.

    2. Decide on a method of storing your lab assigments, so that you can work on them during multiple class sessions. Then save the example program you just ran. e.g. Email your project to yourself, or copy it to your USB drive.

    3. Shut down your lab computer. After it is shut down, wait for a few seconds.

    4. Turn on your lab computer.

    5. Retrieve your program from the email you sent or from your USB drive or other storage location, and then run it using the IntelliJ IDE installed on your lab computer.