Lecture Notes on 10 Jun 2016 Read Chapter 3: Selections Binary Arithmetic - Convert decimal numbers to 8 bit binary - Convert binary numbers to decimal - Represented negative numbers using 2's complement Learning Java * Write the Hello World program * Characterset - ASCII and Unicode * Variables - start with letter, underscore, $ sign followed by n number of letters, digits, and underscores and $ signs it cannot be reserved word * Types - primitive short 16 bits int 32 bits long 64 bits float 32 bits double 64 bits char 16 bits boolean true or false byte 8 bits - reference String Scanner * Declare Variables int wheels; double gpa; char letter; boolean isSunny; String name; * Define variables int wheels = 4; double gpa = 3.56; boolean isSunny = true; char letter = '\u006B'; String name = "Alan"; Scanner sc = new Scanner (System.in); * Operators: - Arithmetic: + - * / % ++ -- - Comparison: < <= > >= == != - Boolean: ! && || ^ - Bitwise - Shift /* File: EasterSunday.java Description: this program computes Easter Sunday using Gauss' algorithm Student Name: John Doe Student UT EID: jd123 Course Name: CS 312 Unique Number: 87525 Date Created: 10 Jun 2016 Date Last Modified: 10 Jun 2016 */ import java.util.Scanner; public class EasterSunday { public static void main (String[] args) { // create the Scanner object Scanner sc = new Scanner (System.in); // prompt user to enter year System.out.print ("Enter year: "); // read the year int y = sc.nextInt (); // compute Easter Sunday using Gauss' algorithm int a = y % 19; // fill in the computations int n = 4; int p = 15; // print out the result if (n == 3) { System.out.println ("\nIn " + y + ", Easter Sunday is on " + p + " March."); } if (n == 4) { System.out.println ("\nIn " + y + ", Easter Sunday is on " + p + " April."); } } }