Howdy. 


  http://www.cs.indiana.edu/classes/c212

  FA17-BL-CSCI-C212-11265

  Gradebook will be set up tonight

  While we still use the sum2017 site:

  Realize you are preparing for C343

  We hope the UI assignments are final and stable

  https://www.cs.indiana.edu/classes/c212-dgerman/sum2017/0619a.html

  http://www.horstmann.com/bigjava.htmlhttps://www.cs.indiana.edu/classes/c212-dgerman/sum2017/0620a.html

  Minute paper attendance questions for today: 

  1. What's the difference between compile time errors and run time errors? 

  2. What is the simplest shortest Java program you can write from Ch. 1? 

  3. Write an algorithm that determines the number of months in which a
     certain investment becomes twice as big. The interest rate per year
     is r, so per month the interest rate that is applied is r/100/12.

There are no check-expects in Java. We use JUnit. See Chapter 8. 

We need to use TDD (test-driven development) in this class and all classes. 

Errors hard to find easy to fix so: be patient.

Welcome to DrRacket, version 6.9 [3m].
Language: Beginning Student; memory limit: 128 MB.
3
The test passed!
> (substring "whatever" 4)
"ever"
> (substring "whatever" 4 7)
"eve"


There's a similar separation of space in DrJava. 

JDK: Java Development Kit. 

.jar means Java Archive.

Java programs are made out of classes. 

At least one class must have a special main method. 

Classes are containers of members (static, non-static). 

Members are: variables and procedures (functions, methods). 

Non-static members belong to the blueprint that creates instances of that class. \

Constructors are not members but they initialize the blueprint upon instantiation. 

public class One {
  public static void main(String[] args) {
    System.out.println("How are you?");
  }
}

This is how it runs in DrJava:

Welcome to DrJava.  Working directory is C:\Users\dgerman\Desktop
> run One
How are you?


What is a type? 

  GNU stands for GNU is Not Unix

  PHP stands for PHP a Hypertext Processor 

A type is a set of values. 
    
In Java there are:

  (a) primitive types

      whole numbers: byte, short, int*, long

      numbers with decimals: float, double*

      truth values: boolean 

      characters: char

  (b) reference types 

      Also called: user-defined types, classes (out of which we create objects)

Operators are specific to types. 

Welcome to DrJava.  Working directory is C:\Users\dgerman\Desktop
> 1
1
> 1 + 2
3
> 2 + 3 * 5
17
> (2 + 3) * 5
25
> 1 - 2 + 3
2
> 1 - (2 + 3)
-4
> 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


See you in lab:

Welcome to DrJava.  Working directory is C:\Users\dgerman\Desktop
> 4.35 * 100
434.99999999999994
> 4.53 * 100
453.0
> BigDecimal a = new BigDecimal(4.35);
Static Error: Undefined class 'BigDecimal'
> import java.math.BigDecimal; // auto-import
BigDecimal a = new BigDecimal(4.35);
> BigDecimal b = new BigDecimal(100);
> a
4.3499999999999996447286321199499070644378662109375
> b
100
> a.multiply(b)
434.9999999999999644728632119949907064437866210937500
> BigDecimal b = new BigDecimal("100");
> b
100
> BigDecimal a = new BigDecimal("4.35");
> a
4.35
> a.multiply(b)
435.00


--