Howdy. UI assignments hopefully final: 

 10092  10:10A-12:05P  F  WY 125: He He (hh25) Yiming Li (liyimi) 
  9113  12:20P-02:15P  F  WY 125: Matthew Lonis (mrlonis) Nick Faro (npfaro)
  9114  02:30P-04:25P  F  GY 226: Tao Hu (taohu) Vinoth Aryan Nagabooshanam (vinaryan)
  9112  04:40P-06:35P  F  GY 226: Ruifeng Zheng (ruifzhen) Jun Wang Pi (wang314)

If you are interested in H212 you are encouraged to switch. 

http://registrar.indiana.edu/browser/soc4178fac/CSCI/CSCI-H212.shtml

https://www.soic.indiana.edu/faculty-research/directory/profile.html?profile_id=357

In C211 we worked in an IDE called DrRacket. 

Attendance questions: 

  1. What is the difference between a compile time error and a run time error. 

  2. Write down the shortest Java program that you have seen in Chapter 1.

  3. Write an algorithm that finds out in how many months a certain amount of
     money becomes double what it was in the beginning if the bank gives you a
     certain interest rate per year (r) that is applied monthly. Monthly this 
     interest rate would then be: r / 100 / 12. 

Don't forget to sign your papers. 

(define (fun n)
  (if (zero? n)
      1
      (* n (fun (- n 1)))))

(check-expect (fun 0) 1)

We should start JUnit slowly soon so you become an expert by the end of the class. 

I will post info about expectation as related to C343. 

In DrRacket the definitions area was purely functional. 

Java programs are made out of classes. 

A class is a container. It contains members (procedures called methods and variables).

A class contains members, they can be static and non-static. 

Non-static members are called: instance members. 

Instance members form a blueprint that is used to create objects from that class. 

Constructors are not members but initialization procedures for object instantiation.

http://drjava.sourceforge.net/

A .jar file means a Java archive. 

Download and run DrJava the .jar file. 

For Windows you need to download the JDK and then the .jar file for DrJava. 

In DrJava we have a similar setup like in DrRacket. 

A type is a set of values. 

Base two count from 0 to 8:

       0
       1
      10
      11
     100
     101
     110
     111
    1000

Seventeen in base 2:

    17

    10001

Challenge: 

   Can you prove that seven is half of twelve. 

One answer: use roman numerals and cover the lower half of XII.

Hint for the second solution: what is 12 in base 12? 

hat does 12 mean if it's written in base 12?

12 in base 12 means 1 * 12 + 2 == 14 in base 10. 

So in base 12 7 is indeed half of 12. 

Java has four (eight) prmitive types:

   integers (whole numbers): byte, short, int*, long
   floating-point numbers: float, double*
   truth values: boolean 
   characters: char 

Everything else is not a primitive type, instead they go by names such as:

   reference types
   user-defined types
   classes (the values are the objects you create from it) 

The other part is the set of operators that belong to a type: 

   numbers: + * - / % 
            < != == <= (relational operators)
   truth values: && || and the unary operator !

What is a String? 

A String is a reference types but it's so ubiquitous don't confuse it with a primitive type. 
 
Welcome to DrJava.  Working directory is C:\Users\dgerman
> 1
1
> 1.25
1.25
> 1 + 2
3
> 1 - 2 + 3
2
> 1 - (2 + 3)
-4
> 2 + 3 * 4
14
> (2 + 3) * 4
20
> 1 / 2 * 2
0
> 2 * 1 / 2
1
> 1 / 2
0
> 5 / 2
2
> 5 % 2
1
> 17 % 3
2
> 2 % 3
2
> 0.1
0.1
> 0.1 + 0.1
0.2
> 0.1 + 0.1 + 0.1
0.30000000000000004
> 0.1 + 0.1 + 0.1 + 0.1 
0.4
> 0.1 + 0.1 + 0.1 + 0.1 + 0.1
0.5
> 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1
0.6
> 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1
0.7
> 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1
0.7999999999999999
> 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 
0.8999999999999999
> 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1
0.9999999999999999
> 4.53 * 100
453.0
> 4.35 * 100
434.99999999999994


how do we fix this? 

Welcome to DrJava.  Working directory is C:\Users\dgerman
> import java.math.BigDecimal; 
> BigDecimal a = new BigDecimal("4.35")
> BigDecimal b = new BigDecimal("100")
> a.multiply(b)
435.00